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

Skip progress report when Content-Length is unavailable #86

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/mini_portile2/mini_portile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,14 @@ def download_file_http(url, full_path, count = 3)
"Accept-Encoding" => 'identity',
:content_length_proc => lambda{|length| total = length },
:progress_proc => lambda{|bytes|
new_progress = (bytes * 100) / total
message "\rDownloading %s (%3d%%) " % [filename, new_progress]
progress = new_progress
if total
new_progress = (bytes * 100) / total
message "\rDownloading %s (%3d%%) " % [filename, new_progress]
progress = new_progress
else
# Content-Length is unavailable because Transfer-Encoding is chunked
message "\rDownloading %s " % [filename]
end
}
}
proxy_uri = URI.parse(url).scheme.downcase == 'https' ?
Expand Down