mirror of
https://github.com/restic/restic.git
synced 2025-10-09 23:14:08 +00:00
Enable sparseness only conditionally
We can either preallocate storage for a file or sparsify it. This detects a pack file as sparse if it contains an all zero block or consists of only one block. As the file sparsification is just an approximation, hide it behind a `--sparse` parameter.
This commit is contained in:
@@ -8,6 +8,10 @@ import "bytes"
|
||||
// WriteAt writes p to f.File at offset. It tries to do a sparse write
|
||||
// and updates f.size.
|
||||
func (f *partialFile) WriteAt(p []byte, offset int64) (n int, err error) {
|
||||
if !f.sparse {
|
||||
return f.File.WriteAt(p, offset)
|
||||
}
|
||||
|
||||
n = len(p)
|
||||
end := offset + int64(n)
|
||||
|
||||
|
Reference in New Issue
Block a user