Skip to content

fix(repository): skip unreadable snapshot files when listing all snapshots - #651

Open
Akayashuu wants to merge 3 commits into
rustic-rs:mainfrom
Akayashuu:fix/snapshots-skip-unreadable
Open

Akayashuu wants to merge 3 commits into
rustic-rs:mainfrom
Akayashuu:fix/snapshots-skip-unreadable

Conversation

@Akayashuu

@Akayashuu Akayashuu commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #641

A single snapshot file that cannot be read or decrypted made get_all_snapshots, get_matching_snapshots, update_all_snapshots and update_matching_snapshots fail. This follows the fix suggested in the issue.

Changes

  • update_from_backend warns and skips unreadable files, with the same Error reading snapshot: {err} message iter_all_from_backend uses. fill_missing takes a small private UnreadableSnapshot enum (Fail or Skip) to choose that.
  • update_from_ids and from_strs still return the error: a snapshot asked for by id that cannot be read is an error.
  • check_repository, which backs both check and check_with_trees, reads every snapshot file in parallel and reports each unreadable one as CheckError::ErrorReadingFile with file_type: Snapshot. It has to sit there rather than in Repository::check, because the rustic CLI loads snapshots with get_matching_snapshots and then calls check_with_trees. Without it, rustic check would only print a warning and exit successfully. The cost is one more read of each snapshot file during check, which goes through the cache when there is one.
  • The # Note of get_matching_snapshots and update_matching_snapshots says that unreadable files are skipped.

What else this touches

  • prune loads snapshots through its own stream_list and keeps the error, so it still refuses to run with an unreadable snapshot. That matters, because skipping one there would mark its blobs as unused.
  • check_with_trees now also reports unreadable snapshot files that are not among the given trees. That matches how check already looks at every index and pack file, whatever trees it is given.
  • In this crate, check is the only internal caller of these listing functions.
  • A caller outside the crate that computes used blobs from these functions would now miss the blobs of an unreadable snapshot. In rustic (at 143d073), the callers are listing, filtering, grouping and the TUI, while used blobs come from prune.

Tests

Four integration tests in tests/integration/snapshots.rs set up two snapshots and overwrite one file with garbage:

  • get_all_snapshots returns the readable one (fails on main),
  • get_snapshots with the id of the broken one fails (passes on main, kept as a guard),
  • check reports ErrorReadingFile with that id (fails on main),
  • check_with_trees with the trees of the listed snapshots, as the CLI does, reports it too.

The two check tests also fail if only the listing part of the fix is kept.

The PR CI also fails on main because of the Rust 1.99 lints fixed in #648. With that commit applied, cargo +stable fmt --all -- --check, cargo +stable clippy --all-targets --all-features -- -D warnings and cargo +stable test -p rustic_core --all-features pass locally.

Akayashuu and others added 3 commits November 6, 2026 19:33
…shots

One damaged snapshot file made get_all_snapshots and the functions built
on it fail, so a single bad file blocked listing, forget and check.
Listing now warns and skips it, like iter_all_from_backend already does.
Snapshots requested by id still fail.

check reads every snapshot file which could not be listed again and
reports each one as ErrorReadingFile, so it does not get quieter.
The rustic CLI lists snapshots with get_matching_snapshots and then
calls check_with_trees, so reporting unreadable snapshot files only in
Repository::check let rustic check succeed with a warning. Read every
snapshot file in check_repository instead, which backs both.
…unreadable

# Conflicts:
#	crates/core/src/commands/check.rs
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.

get_all_snapshots() fails as a whole when one snapshot file can't be read

1 participant