Skip to content

Commit

Permalink
Make sure maxImageCount images are downloaded if an image dl has failed
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderhenne committed Feb 18, 2018
1 parent f8b76f5 commit 49c8212
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,15 @@ function download(anchor) {
}

if (children.length === 0 || toDownloadCount >= maxImageCount || result.data.after === null) {
var reasonWasMaxImageCount = toDownloadCount >= maxImageCount;

checkFinishedInterval = setInterval(function() {
if (downloadedCount === toDownloadCount) {
if (reasonWasMaxImageCount && toDownloadCount < maxImageCount) {
// this happens if an image has failed to download
// and we need to try to download more images
clearInterval(checkFinishedInterval);
download(result.data.after);
} else if (downloadedCount === toDownloadCount) {
doneDownloading();
}
}, CHECK_DOWNLOADS_FINISHED_EVERY_MS);
Expand Down

0 comments on commit 49c8212

Please sign in to comment.