Repository navigation
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #641
A single snapshot file that cannot be read or decrypted made
get_all_snapshots,get_matching_snapshots,update_all_snapshotsandupdate_matching_snapshotsfail. This follows the fix suggested in the issue.Changes
update_from_backendwarns and skips unreadable files, with the sameError reading snapshot: {err}messageiter_all_from_backenduses.fill_missingtakes a small privateUnreadableSnapshotenum (FailorSkip) to choose that.update_from_idsandfrom_strsstill return the error: a snapshot asked for by id that cannot be read is an error.check_repository, which backs bothcheckandcheck_with_trees, reads every snapshot file in parallel and reports each unreadable one asCheckError::ErrorReadingFilewithfile_type: Snapshot. It has to sit there rather than inRepository::check, because the rustic CLI loads snapshots withget_matching_snapshotsand then callscheck_with_trees. Without it,rustic checkwould 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.# Noteofget_matching_snapshotsandupdate_matching_snapshotssays that unreadable files are skipped.What else this touches
pruneloads snapshots through its ownstream_listand 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_treesnow 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.checkis the only internal caller of these listing functions.prune.Tests
Four integration tests in
tests/integration/snapshots.rsset up two snapshots and overwrite one file with garbage:get_all_snapshotsreturns the readable one (fails onmain),get_snapshotswith the id of the broken one fails (passes onmain, kept as a guard),checkreportsErrorReadingFilewith that id (fails onmain),check_with_treeswith 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
mainbecause 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 warningsandcargo +stable test -p rustic_core --all-featurespass locally.