Skip to content

🐛 fix(zipapp): publish extracted files atomically - #3608

Merged
gaborbernat merged 4 commits into
pypa:mainfrom
gaborbernat:fix/atomic-zipapp-extraction
Nov 20, 2026
Merged

gaborbernat merged 4 commits into
pypa:mainfrom
gaborbernat:fix/atomic-zipapp-extraction

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

The zipapp resource extraction path wrote directly to the cache destination. If copying stopped partway through, a later run could reuse the partial file. Extraction now finishes in a sibling temporary file and publishes the completed file with os.replace. Fixes #3607.

Interrupted extraction

The old ZipFile.extract call opened the final path before the copy finished. The new extraction path writes beside the destination and replaces it only after copying succeeds. Creating the file directly in the cache directory also lets it inherit that directory's access permissions. The Windows path helper keeps the temporary path usable when the cache location is near the Windows path limit.

Behavior changes

An extraction error leaves any previous cache file in place and removes the temporary file. The caller still receives the extraction error.

Report ANT-2026-CSTVVSC1.

pre-commit-ci Bot and others added 3 commits November 19, 2026 23:03
Windows gives TemporaryDirectory an owner-only ACL. Files moved from it
keep that ACL, which can deny other readers of a shared cache. Stage the
extraction in a sibling file created directly in the cache directory.

Update the CodeQL mutant patch to match the refactored delete helper.
@gaborbernat
gaborbernat merged commit 1622076 into pypa:main Nov 20, 2026
81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interrupted zipapp extraction leaves a partial cached file

1 participant