Repository navigation
Conversation
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.
Fixes #593
Problem
restore_contentsunwraps every fallible call in its worker tasks: reading the pack, decrypting a blob, reading from an existing file, setting a file's length, writing data. Any failure panics a worker. Withpanic = "abort"in rustic's release profile, the whole process aborts (exit code 134) with a panic message instead of an error, and the metadata of the restored files isn't set.Two example ways to get there with rustic 0.11.4:
EACCESpanics atrestore.rs:658(set_length)restore.rs:643(read_encrypted_from_partial)Fix
The tasks record the first error in a shared slot. Once it is set, the remaining tasks skip their work, and
restore_contentsreturns the error after the thread pool has finished. Errors of the destination becomeErrorKind::InputOutputwith the file's path as context, like the existing error for setting the length of empty files a few lines above. The// TODO: error handling!comment is gone.The restore now stops at the first error: tasks that are already running finish, the others do nothing.
If you'd rather continue with the other files and report all errors at the end, that's a small change to how the slot is used.
sizes.lock().unwrap()stays: the mutex can only be poisoned by a panic, and there's none left.Tests
test_restore_damaged_pack_returns_error: flips a byte in a file's data blob, so the pack keeps its length) and restores.test_restore_over_read_only_file_returns_error(Unix only): restores over a read-only file in a read-only directory. Skipped when running as root, where mode bits aren't enforced.