Ensure sparse files on windows during download
@@ -216,6 +216,9 @@ func (b *blobDownload) run(ctx context.Context, requestURL *url.URL, opts *regis
return err
}
defer file.Close()
+ if err := setSparse(file); err != nil {
+ return err
+ }
_ = file.Truncate(b.Total)
@@ -0,0 +1,9 @@
+//go:build !windows
+
+package server
+import "os"
+func setSparse(file *os.File) error {
+ return nil
+}
@@ -0,0 +1,16 @@
+import (
+ "os"
+ "golang.org/x/sys/windows"
+)
+ return windows.DeviceIoControl(
+ windows.Handle(file.Fd()), windows.FSCTL_SET_SPARSE,
+ nil, 0,
+ nil, nil,
+ )