iTaybb / pySmartDL

A Smart Download Manager for Python
The Unlicense
198 stars 56 forks source link

Fix truncated byte (issue #35) #40

Closed ghost closed 5 years ago

ghost commented 5 years ago

This should do the job to solve issue #35

Tested with file sizes / threads from #35 , and with more than 10000 size/thread configuration.

codecov[bot] commented 5 years ago

Codecov Report

Merging #40 into master will decrease coverage by 6.46%. The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #40      +/-   ##
=======================================
- Coverage   80.46%   74%   -6.47%     
=======================================
  Files           5     5              
  Lines         650   650              
=======================================
- Hits          523   481      -42     
- Misses        127   169      +42
Impacted Files Coverage Δ
pySmartDL/pySmartDL.py 71.97% <100%> (-5.5%) :arrow_down:
pySmartDL/utils.py 77.95% <0%> (-12.6%) :arrow_down:
pySmartDL/download.py 71.21% <0%> (-9.1%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 4e71c18...de9aa25. Read the comment docs.

iTaybb commented 5 years ago

Nice catch. Let me inspect it and I'll merge it soon.

iTaybb commented 5 years ago

So, few notes:

  1. The rounding issue is from the python2 ages. Thanks for that. I believe this will fix the bug.

  2. I wonder regarding the fix of the filesize-1. Since this issue seems to be an off-by-one issue, it might be the solution. However I'm quite baffled: since the bytes count goes from 0 to filesize-1 (inclusive), we cannot request byte filesize. For example, if we're downloading a 5 bytes file, we would request bytes 0 to 4. Requesting byte would be an error.

What do you think?

ghost commented 5 years ago

Yes you are totally right, the filesize-1 to filesize won't fix anything !

I will push a correction :)

ghost commented 5 years ago

Done

And I also round the filesize/threads in the while (threads number verification) like you said before editing your post, I think it is indeed better to check with the same chunck size we will have after