You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Randomly (that happened 20% of the times so far) when trying to download files in bulk (900MB - 600 files) the queue gets stuck and it stops emitting events:
this is the code I'm using to set up the bulk download:
DownloadContext.Builder builder = new DownloadContext.QueueSet()
.setParentPathFile(new File(context.getCacheDir().toString() + File.separator + "tmpapp"))
.setMinIntervalMillisCallbackProcess(300)
.commit();
for (int i = 0; i < downloadTasks.size(); i++) {
//downloadTasks list of MyDownloadTaskClass
MyDownloadTaskClass task = downloadTasks.get(i);
builder.bind(task.url).addTag(0, task.filename).addTag(1, task.savedDir).addTag(2, task.finalDir).addTag(3, i);
}
DownloadContext downloadContext = builder.setListener(new DownloadContextListener() {
@Override
public void taskEnd(@NonNull DownloadContext context, @NonNull com.liulishuo.okdownload.DownloadTask task, @NonNull EndCause cause, @Nullable Exception realCause, int remainCount) {
final int index = (int) task.getTag(3);
synchronized (updateFileNumberLock) {
switch (cause) {
case COMPLETED:
break;
case PRE_ALLOCATE_FAILED:
case FILE_BUSY:
case ERROR:
case CANCELED:
log("failed at index " + index);
if (index < downloadTasks.size()) {
failedTasks.add(downloadTasks.get(index));
failedDownloads++;
}
break;
}
downloadedFiles++;
}
}
@Override
public void queueEnd(@NonNull DownloadContext context) {
//downloadFinished variable used to exit the service loop and hide the foreground notification
downloadFinished = true;
log("QUEUE END");
}
}).build();
downloadContext.start(
new DownloadListener() {
@Override
public void taskStart(@NonNull com.liulishuo.okdownload.DownloadTask task) {
Log.e("DOWNLOADCONTEXT", "taskStart "+ task.getFilename());
cyclesWithouUpdate = 0; //update received reset the counter
}
@Override
public void connectTrialStart(@NonNull com.liulishuo.okdownload.DownloadTask task, @NonNull Map<String, List<String>> requestHeaderFields) {
Log.e("DOWNLOADCONTEXT", "connectTrialStart "+ task.getFilename());
cyclesWithouUpdate = 0; //update received reset the counter
}
@Override
public void connectTrialEnd(@NonNull com.liulishuo.okdownload.DownloadTask task, int responseCode, @NonNull Map<String, List<String>> responseHeaderFields) {
Log.e("DOWNLOADCONTEXT", "connectTrialEnd "+ task.getFilename());
cyclesWithouUpdate = 0; //update received reset the counter
}
@Override
public void downloadFromBeginning(@NonNull com.liulishuo.okdownload.DownloadTask task, @NonNull BreakpointInfo info, @NonNull ResumeFailedCause cause) {
Log.e("DOWNLOADCONTEXT", "downloadFromBeginning "+ task.getFilename());
cyclesWithouUpdate = 0; //update received reset the counter
}
@Override
public void downloadFromBreakpoint(@NonNull com.liulishuo.okdownload.DownloadTask task, @NonNull BreakpointInfo info) {
Log.e("DOWNLOADCONTEXT", "downloadFromBreakpoint "+ task.getFilename());
cyclesWithouUpdate = 0; //update received reset the counter
}
@Override
public void connectStart(@NonNull com.liulishuo.okdownload.DownloadTask task, int blockIndex, @NonNull Map<String, List<String>> requestHeaderFields) {
Log.e("DOWNLOADCONTEXT", "connectStart "+ task.getFilename());
cyclesWithouUpdate = 0; //update received reset the counter
}
@Override
public void connectEnd(@NonNull com.liulishuo.okdownload.DownloadTask task, int blockIndex, int responseCode, @NonNull Map<String, List<String>> responseHeaderFields) {
Log.e("DOWNLOADCONTEXT", "connectEnd "+ task.getFilename());
cyclesWithouUpdate = 0; //update received reset the counter
}
@Override
public void fetchStart(@NonNull com.liulishuo.okdownload.DownloadTask task, int blockIndex, long contentLength) {
Log.e("DOWNLOADCONTEXT", "fetchStart "+ task.getFilename());
cyclesWithouUpdate = 0; //update received reset the counter
}
@Override
public void fetchProgress(@NonNull com.liulishuo.okdownload.DownloadTask task, int blockIndex, long increaseBytes) {
Log.d("DOWNLOADCONTEXT", "fetchProgress "+ task.getFilename());
cyclesWithouUpdate = 0; //update received reset the counter
}
@Override
public void fetchEnd(@NonNull com.liulishuo.okdownload.DownloadTask task, int blockIndex, long contentLength) {
Log.d("DOWNLOADCONTEXT", "fetchEnd "+ task.getFilename());
cyclesWithouUpdate = 0; //update received reset the counter
}
@Override
public void taskEnd(@NonNull final com.liulishuo.okdownload.DownloadTask task, @NonNull final EndCause cause, @Nullable final Exception realCause) {
Log.d("DOWNLOADCONTEXT", "taskEnd "+ task.getFilename());
cyclesWithouUpdate = 0; //update received reset the counter
}
}, false);
while (!downloadFinished) {
log("CHECK LOOP cyclesWithouUpdate " + cyclesWithouUpdate + " downloadedFiles " + downloadedFiles + " failedDownloads " + failedDownloads + " progress " + (downloadedFiles - failedDownloads) * 100 / totalFiles);
//after not receiving updates for 60 seconds I kill the queue and retry stuck downloads
if(cyclesWithouUpdate > 60){
log("cyclesWithouUpdate > 60 stop and retry failedTasks "+failedTasks.size());
downloadContext.stop();
}
setForegroundAsync(updateNotification(context, notificationName, DownloadStatus.RUNNING, (downloadedFiles - failedDownloads) * 100 / totalFiles, null));
cyclesWithouUpdate++;
Thread.sleep(1000);
}
OkDownload Version
1.0.7
Problem Describe
Randomly (that happened 20% of the times so far) when trying to download files in bulk (900MB - 600 files) the queue gets stuck and it stops emitting events:
this is the code I'm using to set up the bulk download:
Log
The text was updated successfully, but these errors were encountered: