iTaybb / pySmartDL

A Smart Download Manager for Python
The Unlicense
194 stars 57 forks source link

Last byte is truncated for file with specific size and specific number of threads #35

Closed panpawel88 closed 4 years ago

panpawel88 commented 5 years ago

Hello,

I use pySmartDL 1.3.2 on Ubuntu 18.04. I noticed that the last byte of a downloaded file is truncated, when a file size is 1906023034 and a number of threads is 20.

Reproduction steps:

  1. Generate a file with size 1906023034. I used 'fallocate' command: $ fallocate -l 1906023034 test_file
  2. Put a test file on HTTP server. I used nginx, but any server which supports multiple connections and range-based requests shall be fine.
  3. Download a file. Here is my program:
    
    import logging
    import tempfile

from pySmartDL import SmartDL

if name == 'main': logging.basicConfig(level=logging.DEBUG) urls = [ 'http://localhost:8000/test_file'] tempdir = tempfile.mkdtemp() obj = SmartDL(urls=urls, dest=tempdir, threads=20, logger=logging.getLogger(name)) obj.timeout = 30 obj.start(blocking=True)



4. Verify file size after download:
$ du -b test_file
1906023033      test_file

I also noticed that if you use 100 threads, then the file size is correct.
ghost commented 4 years ago

Same error with a file size of 261969919 and 32 threads, I got a file with size 261969918. Same error with 4, 8, 16, 32 or 64 threads, ... (always with the same file), but works fine with 128 and 256 threads... ! Works fine with 30, (not 32!), 31, 33, 34, 35, 36, 37, 38, 39 or 40 threads with the same file.

With a file size of 351272960, seems to work with all thread configurations...

Can you look into this please ? Seems to be a very critical bug... thank you! (I can donate if needed, i realy need this lib^^ )

(I use pySmartDL 1.3.2 on Windows 10)

iTaybb commented 4 years ago

I'll look into it.

ghost commented 4 years ago

Thank you 🙏 (If you have a bitcoin wallet give me your address in pvt I will make you a donation when the fix will be released, if you want)

iTaybb commented 4 years ago

Thanks for the hard work.