Skip to content

fix(prune): don't rewrite index files that the indexer wrote full - #687

Merged
aawsome merged 1 commit into
rustic-rs:mainfrom
DamienStevens:fix/prune-full-index-files
Dec 4, 2026
Merged

aawsome merged 1 commit into
rustic-rs:mainfrom
DamienStevens:fix/prune-full-index-files

Conversation

@DamienStevens

Copy link
Copy Markdown
Contributor

Closes #679

MIN_INDEX_LEN was compared with the number of packs in an index file, while the indexer fills files up to 50,000 blobs. So with two or more index files every prune rewrote all of them, even with nothing to delete or repack.

Change

  • PruneIndex.len counts blobs, the same unit as the indexer's MAX_COUNT, so a file the indexer wrote full is no longer "too small".
  • Small index files are rebuilt only when something else is rebuilt anyway, or when there are at least two of them to merge. One small file next to full ones is left alone. Before, that guard covered only a repository with exactly one index file.

Prune now reaches the nothing to do! return much more often; since #669 the delete marks for unindexed packs are written there.

Test

test_prune_does_not_rewrite_full_index_files in tests/integration/prune.rs: two backups give two index files of 10,500 blobs each. A prune with nothing to do must rebuild no index file and leave both files as they are; on main it rebuilds both (index_files_rebuild is 2). Then an unindexed pack beside the two full files must still be marked and removed by a later prune, and two small index files must still be merged into one. check --read-data passes at the end.

The prune integration tests pass locally, cargo fmt is clean on the changed files, and cargo clippy -p rustic_core --all-targets -- -D warnings reports nothing in them.

@aawsome aawsome 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.

LGTM! Thanks @DamienStevens

@aawsome
aawsome enabled auto-merge December 4, 2026 04:40
@aawsome
aawsome added this pull request to the merge queue Dec 4, 2026
Merged via the queue into rustic-rs:main with commit 6fa4035 Dec 4, 2026
20 of 22 checks passed
@rustic-release-plz rustic-release-plz Bot mentioned this pull request Dec 4, 2026
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.

prune rewrites every index file on every run, even with nothing to delete or repack (MIN_INDEX_LEN counts packs, the indexer counts blobs)

2 participants