-
Notifications
You must be signed in to change notification settings - Fork 13
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
Fixed Issue #55 #56
Fixed Issue #55 #56
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for reporting the issue and providing a patch!
Your solution does not seem unreasonable, but it feels a bit weird using u64::MAX
as a default value. What happens to the progress bar when size
is u64::MAX
in .to_progress_bar(size)
?
What do you think of simply updating the condition to if size_on_disk > 0 && size == size_on_disk
instead? That would prevent the skip.
Also, for the final report to contain the right size by reading on disk, the metadata would need to be refreshed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks much cleaner like that! Good job 👍
Just one or two minor things to clean up and then we can merge it.
src/downloader.rs
Outdated
@@ -260,6 +271,9 @@ impl Downloader { | |||
// Advance the main progress bar. | |||
main.inc(1); | |||
|
|||
// Create a new summary with the real download size | |||
println!("Size on disk {}", size_on_disk); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the println!
.
src/downloader.rs
Outdated
// append: If we can't resume from where we left off, | ||
// we should overrwite the file and start again | ||
// This also prevents corrupting files by writing | ||
// to them again | ||
// write: We are writing to the file | ||
// create: The file should be created if it doesn't exist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation is good to add in general, but in this case I don't think it is necessary to document each member of the builder. They are all well documented in the Tokio documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right, sorry, I completely overlooked that println
, and yeah that's fair
I'll fix both of those quick now
Okay those should be fixed now |
@Aurillium I don't understand why the formatter is not happy, but if you reorder the builder's lines, then is works: let mut file = match OpenOptions::new()
.create(true)
.write(true)
.append(can_resume)
.open(output)
.await; 🤷 |
Interesting haha, but should be all good now |
Pull Request
Types of changes
Fixed issue #55
Description
Summary
u64::MAX
in order to prevent downloads without acontent-length
being skipped for no reason.content-length
Original
Current
Fixed
Issue #55 (files that hadn't been downloaded were being skipped)
Testing
Essentially just the simple example with several different files; the change was very minor (basically a value was changed from 0 to
u64::MAX
, logically everything checks out, and in testing there were no issues)Checklist
Issue #55