mirror of
https://github.com/restic/restic.git
synced 2026-11-21 13:02:42 +00:00
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>