Open skyslide22 opened 4 years ago
Can confirm this bug, it seems to happen quite often here.
EDIT: For anyone interested, I've worked around the problem like this. It might contain some errors as I've only been testing it for 15min in my implementation, but it might help you out as well.
const length = downloadUrls.length;
let downloaded = 0;
downloadUrls.forEach(url => {
DownloadManager.download({ url }, (err, info) => {
if (err) {
console.log(err);
return;
}
// When downloaded, increase the download counter and remove the url from the downloadUrls
downloaded++;
const index = downloadUrls.findIndex(x => x === url);
downloadUrls.splice(index, 1);
// Check if every file has been downloaded, this replaces the callback
if (length === downloaded) {
// Reset download counter
downloaded = 0;
}
})
});
the bulkDownload downloads all files of my array, but it is not triggering the callback, the function body is completly ignored sometimes
the console.log("finished/error etc") is not fired, also the console.log("all files downloaded) is not fired, but all files are downloaded, i see all in the download folder. electron-download-manager just doesn't know when all files are downloaded sometimes.
well, it actually happes randomly, doesnt matter if the files exist before or not ... any idea?
// i wanna add all downloaded files to a ul to read them later with the fs module