restic init generated and uploaded the key file first and only saved the
config afterwards. If two clients ran init against the same empty
repository location at nearly the same time, the backend could end up
with two key files but only one config file, since backends that reject
overwrites let only one of the two config writes succeed. The losing
client's key file stayed in the repository without ever belonging to a
valid config, so clients picking that key later would fail with a
"config or key ... is damaged" error instead of a clear diagnostic.
Reorder Repository.init so the config is saved before the key file is
uploaded. To make that possible, AddKey no longer generates a random
master key internally; callers now supply the master key to encrypt and
store. The two other callers of AddKey (key add, key passwd) already had
an existing key available and pass that through unchanged.
Current benchmarks all work with a single archiver, and are not suitable
for testing changes which might affect contention.
Add a benchmark with multiple small files and multiple concurrent
archivers.
The macOS failure in #22146 reaches the two-second readiness deadline. Give the test server ten seconds to start while retaining immediate readiness and context cancellation handling.
In UpgradeRepo, if upgradeRepository fails, the error handler attempts
contingency rollback by re-uploading the original config file.
However, the contingency path unconditionally executed repo.be.Remove(ctx, h)
before calling repo.be.Save. On backends supporting atomic replacement (such
as local filesystems), a failed upgrade (e.g. out-of-disk-space or permissions
error while writing the temporary file) leaves the original, valid version 1
configuration file completely intact on disk.
Unconditionally removing the config file during rollback actively deletes
the working configuration. If the subsequent Save call also fails, the
repository is left permanently corrupted without a config file.
Condition the pre-removal on !repo.be.Properties().HasAtomicReplace, matching
the forward upgrade path in upgradeRepository. Add a unit test asserting that
aborted upgrades on atomic backends preserve the intact original configuration.
---------
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
When loading or iterating a directory tree failed, traverseTreeInner
returned a nil file list together with the error. If the error handler
ignored the error, the caller still called leaveDir with that nil list,
and restore --delete removed every existing entry of the directory in
the target, even though the expected content was simply unknown.
Force disable deletion in that case, the same way it is already done
for invalid node names.
Signed-off-by: Dean Chen <862469039@qq.com>
The file, blob and size counters were reset for every snapshot, so the
progress line only reflected the last processed snapshot.
Co-authored-by: Winfried Plappert <18740761+wplapper@users.noreply.github.com>
Motivation: when listing pack files fails during prune (for example due
to a request timeout), the error was returned unwrapped and main printed
it with "%+v", which dumps a stack trace. As discussed in the issue, the
error needs one more level of wrapping before it can be treated as a
fatal error.
Approach: in decidePackAction, wrap an error from listing pack files
with errors.Fatalf("failed to list pack files: %v"). Errors that are
already fatal (e.g. ErrSizeNotMatching) and errors after context
cancellation are returned unchanged. The underlying error is preserved
via Unwrap. Retry log messages are unchanged; only the final error
output is shortened and says where the failure occurred.
Validation: `go test ./internal/repository/ -run Prune` and
`go test ./cmd/restic/ -run Prune` pass. The new test
TestPrunePackListError (backend whose pack list fails) fails without
the change and passes with it. I did not reproduce a real REST backend
timeout.
Report: https://github.com/restic/restic/issues/22120
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Assisted-by: claude-sonnet-5-5 (via Claude Code)
Older repair snapshots versions serialized missing subtrees as nodes:null.
The streaming decoder rejects these trees, preventing prune and other
commands from traversing snapshots that previous releases could read.
Accept null as an empty node list. Add decoder coverage and a regression
that prunes, checks and restores a snapshot with a legacy empty subtree.
Replace select based on context/timer with deterministic pattern.
The tests depend on timing. Thus, use synctest which provides
deterministic clock updates and also speeds up test execution by
skipping sleep times.