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

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

Closed
panpawel88 opened this issue Aug 29, 2019 · 4 comments
Labels

Comments

@panpawel88
Copy link

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)
  1. 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.

@iTaybb iTaybb added the bug label Sep 6, 2019
@ghost
Copy link

ghost commented Oct 28, 2019

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
Copy link
Owner

iTaybb commented Oct 28, 2019

I'll look into it.

@ghost
Copy link

ghost commented Oct 28, 2019

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 pushed a commit that referenced this issue Oct 29, 2019
* Fix truncated byte (issue #35)
@iTaybb
Copy link
Owner

iTaybb commented Oct 30, 2019

Thanks for the hard work.

@iTaybb iTaybb closed this as completed Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants