Skip to content

refactor(util): Simplify snapshot zipping - #1014

Merged
dhalperi merged 1 commit into
batfish:masterfrom
progwriter:perf/snapshot-zip
Nov 19, 2026
Merged

dhalperi merged 1 commit into
batfish:masterfrom
progwriter:perf/snapshot-zip

Conversation

@progwriter

Copy link
Copy Markdown
Contributor

ZIP cannot store timestamps before 1980. zip_dir used to copy each
pre-1980 file to a temp file so it picked up a current timestamp, and
skipped that step for directories, so a pre-1980 directory raised
ValueError. Use zipfile's strict_timestamps=False instead, which sets
any pre-1980 timestamp on a file or directory to 1980-01-01. This drops
the extra copy, fixes the directory error, and makes zipping a
snapshot whose files are all pre-1980 about 2.5x faster.

fork_snapshot now zips add_files directories into memory, since the
zip is base64-encoded into the request anyway. This removes a temp
file that was never closed.

@batfish-bot

Copy link
Copy Markdown

This change is Reviewable

ZIP cannot store timestamps before 1980. zip_dir used to copy each
pre-1980 file to a temp file so it picked up a current timestamp, and
skipped that step for directories, so a pre-1980 directory raised
ValueError. Use zipfile's strict_timestamps=False instead, which sets
any pre-1980 timestamp on a file or directory to 1980-01-01. This drops
the extra copy, fixes the directory error, and makes zipping a
snapshot whose files are all pre-1980 about 2.5x faster.

fork_snapshot now zips add_files directories into memory, since the
zip is base64-encoded into the request anyway. This removes a temp
file that was never closed.

@dhalperi dhalperi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhalperi reviewed 3 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on progwriter).

@dhalperi
dhalperi merged commit acaf664 into batfish:master Nov 19, 2026
18 checks passed
@progwriter
progwriter deleted the perf/snapshot-zip branch November 21, 2026 17:07
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.

3 participants