mirror of
https://github.com/ollama/ollama.git
synced 2025-05-11 10:26:53 +02:00
Ensure sparse files on windows during download
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.
This commit is contained in:
parent
86b907f82a
commit
fc85f50a2b
3 changed files with 28 additions and 0 deletions
16
server/sparse_windows.go
Normal file
16
server/sparse_windows.go
Normal file
|
@ -0,0 +1,16 @@
|
|||
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,
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue