Skip to content

Commit cbf9c19

Browse files
author
Ronald Tse
committed
fix(imf): write_parity temp file in the zip's own directory
os.replace across filesystems raises EXDEV — on Modal the zips live on a volume mount while tempfile defaults to /tmp. Same-dir temp keeps the atomic rename.
1 parent 83c163d commit cbf9c19

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎src/imf/parity.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ def write_parity(zip_path: Path | str, report: ParityReport) -> Path:
156156

157157
from imf.pack import _to_dict
158158

159-
with tempfile.TemporaryDirectory() as tmp:
159+
# Same filesystem as the target: os.replace is atomic within one
160+
# filesystem and fails with EXDEV across a volume mount.
161+
with tempfile.TemporaryDirectory(dir=zip_path.parent) as tmp:
160162
rewritten = Path(tmp) / "rewritten.zip"
161163
with zipfile.ZipFile(zip_path) as src, zipfile.ZipFile(
162164
rewritten, "w", zipfile.ZIP_DEFLATED

0 commit comments

Comments
 (0)