restore: fix corrupted sparse files

This commit is contained in:
Michael Eischer
2024-06-05 22:01:55 +02:00
parent 1eccd6504b
commit f1c76a8286
2 changed files with 44 additions and 0 deletions

View File

@@ -153,6 +153,12 @@ func (r *fileRestorer) restoreFiles(ctx context.Context) error {
// in addition, a short chunk will never match r.zeroChunk which would prevent sparseness for short files
file.sparse = r.sparse
}
if file.state != nil {
// The restorer currently cannot punch new holes into an existing files.
// Thus sections that contained data but should be sparse after restoring
// the snapshot would still contain the old data resulting in a corrupt restore.
file.sparse = false
}
if err != nil {
// repository index is messed up, can't do anything