download! method doesn't close file
まだ誰も着手していません。
評価
調査の方向性
download! の実装から始めて、Tempfile がどのように扱われているかを追跡します。Issue にある逐次的なダウンロード/読み取りの例を再現し、その後、ダウンロード直後の読み取りに対するカバレッジを追加または更新します。完了の条件は、呼び出し元がファイルを閉じなくても、読み取りで一貫して完全な内容が得られることです。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Ruby
- スター
- 1.2k
- フォーク
- 256
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
capistrano/sshkit のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
capistrano/sshkit#563 · リアクション 6 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
capistrano/sshkit#562 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
capistrano/sshkit#554 · コメント 3 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
capistrano/sshkit#543 · コメント 2 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
capistrano/sshkit#499 · コメント 1 件 ·
capistrano/sshkit の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
stripe/stripe-ruby#1994 ·
メンテナーはふだん 1 日以内に返信
-
[Fehler]: /abdeckstift wirft 500 — part_type aus der Phonemreduction-Umbenennung nicht mitgezogenオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
wort-schule/wort.schule#787 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
lugassawan/swe-workbench#799 ·
メンテナーはふだん 1 日以内に返信
-
2.8.6: NoMethodError "undefined method 'first'" in profdata_coverage_dir whenever --scheme is usedオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
SlatherOrg/slather#586 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信