fc85f50a2b
The file.Truncate call on windows will write the whole file unless you set the sparse flag, leading to heavy I/O at the beginning of download. This should improve our I/O behavior on windows and put less stress on the users disk.
16 lines
226 B
Go
16 lines
226 B
Go
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,
|
|
)
|
|
}
|