hgouveia / node-downloader-helper

A simple http file downloader for node.js
MIT License
254 stars 55 forks source link

Download completed, file incomplete #118

Open 277584579 opened 5 months ago

277584579 commented 5 months ago

const downloader = new DownloaderHelper( fileURL, filePath, options = { fileName: fileNameTmp, resumeIfFileExists: true, timeout:5000, removeOnStop:false, removeOnFail:false, retry:{ maxRetries:6, delay:5000 }, resumeOnIncomplete:true, resumeOnIncompleteMaxRetry:50 } ); downloader.start() downloader.on('end', (stats) => { console.log(stats) }) image I saw under the "end" callback that incomplete is false, but the size of onDiskSize and downloadedSize are different

hgouveia commented 5 months ago

Hello @277584579 , this is a correct behavior, this can be for many reasons, you could be using a pipe that is doing compression for example, you could be using a pipe to transform the data resulting in a different filesize , or you hard disk has compression enabled too, but if you look at totalSize and downloadedSize the values matches, the library doesnt rely on onDiskSize because of the previous mentioned

277584579 commented 5 months ago

But when I downloaded it and decompressed it, it showed that some files were damaged. How should I solve this problem? This is an occasional issue, not a mandatory occurrence image The same zip file, when I download it again and it displays as shown in the following picture, it is normal, The onDiskSize displayed twice is different image