Skip to content

Commit

Permalink
Add some error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
antonym committed Oct 21, 2023
1 parent 2b514ce commit d6fcc47
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,15 @@ async function downloader(downloads){
var path = value.path;
var dloptions = {override:true,retry:{maxRetries:2,delay:5000}};
var dl = new DownloaderHelper(url, path, dloptions);

dl.on('end', function(){
console.log('Downloaded ' + url + ' to ' + path);
});

dl.on('error', function(error) {
console.error('Download failed:', error);
});

dl.on('progress', function(stats){
var currentTime = new Date();
var elaspsedTime = currentTime - startTime;
Expand All @@ -299,6 +305,7 @@ async function downloader(downloads){
io.emit('dldata', url, [+i + 1,total], stats);
}
});

await dl.start();
if ( ! url.includes('s3.amazonaws.com')){
// Part 2 if exists repeat
Expand Down

0 comments on commit d6fcc47

Please sign in to comment.