kevva/download

Download stop - no event fired

Opened this issue · 0 comments

I am using download to automatically download a couple of video files from a http source. There are some cases where the source file gets overwritten during the download. This probably interrupts the download process. I am trying to catch it whenever the download stops or is interrupted aka "not finished" .

Here is what I have

    download(url)
    .on('downloadProgress', (progress) => {
      console.log(url, Math.round(progress.percent*100), '% downloaded');
    })
    .on('error', (error) => {
      console.log(error.message);
    })
    .on('end', (o) => {
      console.log("finished download of file", data.filename);
    })
    .pipe(writer);

When a download completes, the end event is fired correctly. But I already had a few cases (like I mentioned above) when the download stops (downloadProgress stops firing, no other event is fired) . There is no error event or end event firing.

Are there any other events I can look out for to maybe catch the problem ? Any ideas to account for aborted/canceled/stopped downloads ?