Use PreallocateFile in local backend

This commit is contained in:
DRON-666 2021-02-02 17:44:40 +03:00
parent ffc6b3d887
commit c37d587f81

View file

@ -148,6 +148,13 @@ func (b *Local) Save(_ context.Context, h restic.Handle, rd restic.RewindReader)
}
}(f)
// preallocate disk space
if size := rd.Length(); size > 0 {
if err := fs.PreallocateFile(f, size); err != nil {
debug.Log("Failed to preallocate %v with size %v: %v", finalname, size, err)
}
}
// save data, then sync
wbytes, err := io.Copy(f, rd)
if err != nil {