最後活躍 1 week ago

此組合功能包括一個 Python 腳本和一個 Shell 腳本。Python 腳本用於創建和管理臨時目錄,以存放中間產物;Shell 腳本負責下載指定 URL 的檔案並解壓縮,並在執行完畢後自動清理臨時目錄,確保資源釋放。

timmy 已修改 1 week ago. 還原成這個修訂版本

沒有任何變更

timmy 已修改 3 weeks ago. 還原成這個修訂版本

2 files changed, 9 insertions

create_temporary_directory.py(檔案已創建)

@@ -0,0 +1,5 @@
1 + import tempfile, pathlib
2 +
3 + with tempfile.TemporaryDirectory() as d:
4 + tmp = pathlib.Path(d)
5 + # tmp 下做所有中間產物

download_extract_cleanup.sh(檔案已創建)

@@ -0,0 +1,4 @@
1 + tmpdir="$(mktemp -d)"
2 + trap 'rm -rf "$tmpdir"' EXIT
3 + curl -fsSL "$URL" -o "$tmpdir/input.tar.gz"
4 + tar -xzf "$tmpdir/input.tar.gz" -C "$tmpdir"
上一頁 下一頁