cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cho (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-2787) PhoneGap FileTransfer.Download more than 300 files
Date Mon, 08 Apr 2013 05:53:15 GMT

    [ https://issues.apache.org/jira/browse/CB-2787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13625171#comment-13625171
] 

Cho commented on CB-2787:
-------------------------

If you read the code properly, it is serialized. Download file is a self calling function
where it only callback it self when come into download success routine. When it check counter
== 0 means finish, then it will call DownloadComplete instead.

Let me know if I am doing it wrong.

Thanks.

function DownloadFile() {
  if (counter == 0) {
    DownloadComplete();
    return;
  }

  var ft = new FileTransfer();
  var downloadUrl = "<source>";
  var dlPath = "<target>"

ft.download(downloadUrl, dlPath, function(entry) {
    counter--;
    UpdateProgress();
    DownloadFile();
  }, function(error) {
    DownloadFailed();
  }, true);
}

Regards,
Cho
                
> PhoneGap FileTransfer.Download more than 300 files
> --------------------------------------------------
>
>                 Key: CB-2787
>                 URL: https://issues.apache.org/jira/browse/CB-2787
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 2.5.0
>            Reporter: Cho
>            Assignee: Filip Maj
>
> I had tried to download more than 300 files and then it hit error after that. Seems like
some IO Connection was not properly closed. I wrote a small code to test it out. 
> Any idea? How to file a report or get a source of phonegap to check the real cause?
> {code}
> var counter = 500;
> function DownloadFile() {
>         if (counter == 0) {
>             DownloadComplete();
>             return;
>         }
>         var ft = new FileTransfer();
>         var downloadUrl = "<source>";
>         var dlPath = "<target>"
>         ft.download(downloadUrl, dlPath, function(entry) {
>             counter--;
>             UpdateProgress();
>             DownloadFile();
>         }, function(error) {
>             DownloadFailed();
>         }, true);
>     }
> {code}
> note: <target> and <source> is alright because it was it failed when the
counter goes until 300+.
> {code}
> 03-14 08:35:09.706: E/FileTransfer(24867): {"target":"<target>","source":"<source>","http_status":200,"code":1}
> 03-14 08:35:09.706: E/FileTransfer(24867): java.io.FileNotFoundException: <source>:
open failed: EMFILE (Too many open files)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at libcore.io.IoBridge.open(IoBridge.java:416)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at java.io.FileOutputStream.<init>(FileOutputStream.java:73)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at org.apache.cordova.FileTransfer$4.run(FileTransfer.java:685)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at java.lang.Thread.run(Thread.java:856)
> 03-14 08:35:09.706: E/FileTransfer(24867): Caused by: libcore.io.ErrnoException: open
failed: EMFILE (Too many open files)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at libcore.io.Posix.open(Native Method)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
> 03-14 08:35:09.706: E/FileTransfer(24867):     at libcore.io.IoBridge.open(IoBridge.java:400)
> 03-14 08:35:09.706: E/FileTransfer(24867):     ... 6 more
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message