download! method doesn't close file
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
Research direction
Start at the download! implementation and trace how the Tempfile is handled. Reproduce the sequential download/read example from the issue, then add or update coverage for reading immediately after download; done means the read consistently sees complete contents without the caller closing the file.
Written by the indexing model from the issue text.
Description
which causes hard-to-debug errors when you download many files in a row and try to read the file contents immediately after downloading. It works most of the time, but at some point a downloaded file will not be flushed to disk completely when you try to read the file.
Reading only the partially written file from disk will, of course, result in corrupted file contents. I was able to avoid this behavior by explicitly closing the downloaded file before reading it again. But this was not very intuitive, so please consider closing the file within the download method.
tmp_file = Tempfile.new(file_name, tmp_dir)
src = File.join(dir, file_name)
download! src, tmp_file, log_percent: -1
# it's important to close the tmp file, otherwise data might not be written
# to disk already, when we try to read the file again
tmp_file.close
begin
File.read tmp_file
ensure
tmp_file.close
tmp_file.unlink
end
- Dominant language
- Ruby
- Stars
- 1.2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from capistrano/sshkit
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
capistrano/sshkit#563 · 6 reactions ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
capistrano/sshkit#562 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
capistrano/sshkit#554 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
capistrano/sshkit#543 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
capistrano/sshkit#499 · 1 comment ·
All issues in capistrano/sshkit
Similar issues
-
security
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Mend: dependency security vulnerability
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Mend: dependency security vulnerability
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
homebrew warningsOpen
Difficulty 1/5 Under an hour Newbie friendliness 88/100
bradygaster/squad#2082 ·
Maintainers usually reply within 1 day