restore: support sparse restores also on windows
This commit is contained in:
parent
0f89f443c7
commit
19afad8a09
8 changed files with 129 additions and 63 deletions
19
internal/restorer/truncate_windows.go
Normal file
19
internal/restorer/truncate_windows.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package restorer
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/restic/restic/internal/debug"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
func truncateSparse(f *os.File, size int64) error {
|
||||
// try setting the sparse file attribute, but ignore the error if it fails
|
||||
var t uint32
|
||||
err := windows.DeviceIoControl(windows.Handle(f.Fd()), windows.FSCTL_SET_SPARSE, nil, 0, nil, 0, &t, nil)
|
||||
if err != nil {
|
||||
debug.Log("failed to set sparse attribute for %v: %v", f.Name(), err)
|
||||
}
|
||||
|
||||
return f.Truncate(size)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue