Local range download leaves an output file after source-read failure despite delete_on_failure=True
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
閱讀 libcloud/storage/base.py 中的範圍下載契約,以及 libcloud/storage/drivers/local.py 中的本機實作。重現 issue 中來源缺失的情況,然後在本機驅動程式現有測試旁新增一個迴歸測試。當範圍下載失敗且 delete_on_failure=True 時會刪除目的地,同時旗標為 false 時的行為仍符合預期,即表示完成。
由索引模型根據 Issue 內容生成。
描述
On trunk 8a0ef626, the local driver's range-download method creates a destination file but does not clean it up when opening the source fails, even with delete_on_failure=True.
This reproducer is sequential: obtain the object metadata, explicitly remove the stored file, then try to download. It does not depend on winning a filesystem race.
import os
import tempfile
from libcloud.storage.drivers.local import LocalStorageDriver
with tempfile.TemporaryDirectory() as root:
driver = LocalStorageDriver(root)
container = driver.create_container("bucket")
obj = driver.upload_object_via_stream(iter([b"payload"]), container, "object")
os.unlink(driver.get_object_cdn_url(obj))
destination = os.path.join(root, "download")
try:
driver.download_object_range(
obj, destination, start_bytes=0, delete_on_failure=True
)
except FileNotFoundError:
pass
print(os.path.exists(destination), os.path.getsize(destination))
# True 0
The public range-download contract describes delete_on_failure as deleting a partially downloaded file when the download was unsuccessful, with hash mismatch/file size given as examples. I expected the newly created empty output to be removed for a source-read failure as well. Otherwise a failed operation leaves a file that can be mistaken for a valid empty download.
The local implementation accepts the flag but never reads it. It opens the destination before consuming the source iterator and has no failure cleanup around that loop.
Checks with unchanged source, Python 3.12/Linux:
- Range download with
delete_on_failure=True: raisesFileNotFoundError, leaves a zero-byte output. - Range download with
delete_on_failure=False: same result. - Full
download_objectwith the same missing source: returnsFalse, leaves no output. - Successful range
[0, 3)before removing the source: returnsTrue, writesb"pay".
No code change yet. This report is limited to failure cleanup for local range downloads; it does not claim a concurrent-write reproduction or a full test-suite pass.
- 主要語言
- Python
- 星號
- 2.1k
- 分支
- 935
- 平均合併
- 5 天 3 小時
- 30 天內合併 PR
- 15
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
apache/libcloud 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
難度 1/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 15/100
apache/libcloud#2215 · 3 則留言 · 2 個 reaction ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 35/100
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 15/100
維護者通常 1 天內回覆
相似的 Issue
-
Email validation accepts a trailing newline可能已有人在做 @marcello-pichini 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
dbt-labs/spark-utils#51 ·
-
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆
-
bug frontend
難度 2/5 1-3 小時 新手友好度 88/100
vendrabuck/HERD#1419 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆