Skip to content

Conversation

@MarcelBochtler
Copy link
Contributor

No description provided.

@MarcelBochtler MarcelBochtler changed the title Validate zip files to validate cache files Add cache validation and atomic file operations Nov 28, 2025
@MarcelBochtler MarcelBochtler force-pushed the bad-zip-file branch 2 times, most recently from ccf48ca to c752c84 Compare November 28, 2025 16:32
@MarcelBochtler MarcelBochtler marked this pull request as ready for review November 28, 2025 16:35
Signed-off-by: Marcel Bochtler <[email protected]>
We've seen corrupted wheel files in Python Inspector's cache leading to
`BadZipFile` exceptions.
Add additional validation that ensures that files that will be reused
from the cache are actual zip files.

Signed-off-by: Marcel Bochtler <[email protected]>
When downloading and caching files such as Python wheels, eggs, or zip
files, it's crucial to ensure that the files are fully and correctly
written before they are made available for use.
This change implements atomic file operations by writing to a temporary
file first and then renaming it to the target filename once the write is
complete and the file has been validated.
This prevents issues where a partially written or corrupt file could be
read by other processes.

Signed-off-by: Marcel Bochtler <[email protected]>
Wrap cache file read in try-except to handle race condition where
another async task deletes the file between validation and lock
acquisition.
Automatically retry with force=True to trigger re-download.

Signed-off-by: Marcel Bochtler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant