Unverified Commit a4fdd03c authored by Daniel Hiltgen's avatar Daniel Hiltgen Committed by GitHub
Browse files

Merge pull request #6207 from dhiltgen/sparse_win

Ensure sparse files on windows during download
parents 86b907f8 fc85f50a
...@@ -216,6 +216,9 @@ func (b *blobDownload) run(ctx context.Context, requestURL *url.URL, opts *regis ...@@ -216,6 +216,9 @@ func (b *blobDownload) run(ctx context.Context, requestURL *url.URL, opts *regis
return err return err
} }
defer file.Close() defer file.Close()
if err := setSparse(file); err != nil {
return err
}
_ = file.Truncate(b.Total) _ = file.Truncate(b.Total)
......
//go:build !windows
package server
import "os"
func setSparse(file *os.File) error {
return nil
}
package server
import (
"os"
"golang.org/x/sys/windows"
)
func setSparse(file *os.File) error {
return windows.DeviceIoControl(
windows.Handle(file.Fd()), windows.FSCTL_SET_SPARSE,
nil, 0,
nil, 0,
nil, nil,
)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment