mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
local fs rename: if it fails with a cross device error try a copy
I don't want to add a new setting for this, at least until we get the first complain for a slow rename :) Fixes #440
This commit is contained in:
36
vfs/sys_unix.go
Normal file
36
vfs/sys_unix.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// +build !windows
|
||||
|
||||
package vfs
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var (
|
||||
defaultUID, defaultGID int
|
||||
)
|
||||
|
||||
func init() {
|
||||
defaultUID = os.Getuid()
|
||||
defaultGID = os.Getuid()
|
||||
if defaultUID < 0 {
|
||||
defaultUID = 65534
|
||||
}
|
||||
if defaultGID < 0 {
|
||||
defaultGID = 65534
|
||||
}
|
||||
}
|
||||
|
||||
func (fi FileInfo) getFileInfoSys() interface{} {
|
||||
return &syscall.Stat_t{
|
||||
Uid: uint32(defaultUID),
|
||||
Gid: uint32(defaultGID)}
|
||||
}
|
||||
|
||||
func isCrossDeviceError(err error) bool {
|
||||
return errors.Is(err, unix.EXDEV)
|
||||
}
|
||||
Reference in New Issue
Block a user