mirror of
https://github.com/rclone/rclone.git
synced 2024-11-29 20:04:52 +01:00
23 lines
395 B
Go
23 lines
395 B
Go
//+build linux
|
|
|
|
package local
|
|
|
|
import (
|
|
"os"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
// preAllocate the file for performance reasons
|
|
func preAllocate(size int64, out *os.File) error {
|
|
if size <= 0 {
|
|
return nil
|
|
}
|
|
err := unix.Fallocate(int(out.Fd()), unix.FALLOC_FL_KEEP_SIZE, 0, size)
|
|
// FIXME could be doing something here
|
|
// if err == unix.ENOSPC {
|
|
// log.Printf("No space")
|
|
// }
|
|
return err
|
|
}
|