mirror of
https://github.com/restic/restic.git
synced 2026-11-21 21:12:42 +00:00
repository: do not delete config on atomic backends during upgrade rollback (#22136)
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>
This commit is contained in:
1 parent
c904b78998
commit
2c9b353cbf
4 files changed
+50
-7
No files matched your search
@@ -36,5 +36,5 @@ func (*UpgradeRepoV2) RepoCheck() bool {
|
||||
}
|
||||
|
||||
func (m *UpgradeRepoV2) Apply(ctx context.Context, repo restic.Repository) error {
|
||||
return repository.UpgradeRepo(ctx, repo.(*repository.Repository))
|
||||
return repository.UpgradeRepo(ctx, repo.(*repository.Repository), "")
|
||||
}
|
||||
Reference in new issue
Block a user