Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some error handling #44

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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