forked from TrueCloudLab/restic
repair snapshots: Always sanitize file nodes
If the node for a file is intact, this is a no-op.
This commit is contained in:
parent
4ce87a7f64
commit
f6cc10578d
1 changed files with 7 additions and 9 deletions
|
@ -107,7 +107,7 @@ func runRepairSnapshots(ctx context.Context, gopts GlobalOptions, opts RepairOpt
|
||||||
}
|
}
|
||||||
|
|
||||||
ok := true
|
ok := true
|
||||||
var newContent restic.IDs
|
var newContent restic.IDs = restic.IDs{}
|
||||||
var newSize uint64
|
var newSize uint64
|
||||||
// check all contents and remove if not available
|
// check all contents and remove if not available
|
||||||
for _, id := range node.Content {
|
for _, id := range node.Content {
|
||||||
|
@ -119,15 +119,13 @@ func runRepairSnapshots(ctx context.Context, gopts GlobalOptions, opts RepairOpt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
if newSize == 0 {
|
Verbosef(" file %q: removed missing content\n", path)
|
||||||
Printf("removed defective file '%v'\n", path+node.Name)
|
} else if newSize != node.Size {
|
||||||
node = nil
|
Verbosef(" file %q: fixed incorrect size\n", path)
|
||||||
} else {
|
|
||||||
Printf("repaired defective file '%v'\n", path+node.Name)
|
|
||||||
node.Content = newContent
|
|
||||||
node.Size = newSize
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// no-ops if already correct
|
||||||
|
node.Content = newContent
|
||||||
|
node.Size = newSize
|
||||||
return node
|
return node
|
||||||
},
|
},
|
||||||
RewriteFailedTree: func(nodeID restic.ID, path string, _ error) (restic.ID, error) {
|
RewriteFailedTree: func(nodeID restic.ID, path string, _ error) (restic.ID, error) {
|
||||||
|
|
Loading…
Reference in a new issue