mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-08-24 06:31:59 +08:00
weed filer.copy: use existing file owner and gropu id
This commit is contained in:
parent
a32abda1a3
commit
d14b614407
@ -170,11 +170,15 @@ func genFileCopyTask(fileOrDir string, destPath string, fileCopyTaskChan chan Fi
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uid, gid := util.GetFileUidGid(fi)
|
||||||
|
|
||||||
fileCopyTaskChan <- FileCopyTask{
|
fileCopyTaskChan <- FileCopyTask{
|
||||||
sourceLocation: fileOrDir,
|
sourceLocation: fileOrDir,
|
||||||
destinationUrlPath: destPath,
|
destinationUrlPath: destPath,
|
||||||
fileSize: fi.Size(),
|
fileSize: fi.Size(),
|
||||||
fileMode: fi.Mode(),
|
fileMode: fi.Mode(),
|
||||||
|
uid: uid,
|
||||||
|
gid: gid,
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -200,6 +204,8 @@ type FileCopyTask struct {
|
|||||||
destinationUrlPath string
|
destinationUrlPath string
|
||||||
fileSize int64
|
fileSize int64
|
||||||
fileMode os.FileMode
|
fileMode os.FileMode
|
||||||
|
uid uint32
|
||||||
|
gid uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (worker *FileCopyWorker) doEachCopy(ctx context.Context, task FileCopyTask) error {
|
func (worker *FileCopyWorker) doEachCopy(ctx context.Context, task FileCopyTask) error {
|
||||||
@ -287,8 +293,8 @@ func (worker *FileCopyWorker) uploadFileAsOne(ctx context.Context, task FileCopy
|
|||||||
Attributes: &filer_pb.FuseAttributes{
|
Attributes: &filer_pb.FuseAttributes{
|
||||||
Crtime: time.Now().Unix(),
|
Crtime: time.Now().Unix(),
|
||||||
Mtime: time.Now().Unix(),
|
Mtime: time.Now().Unix(),
|
||||||
Gid: uint32(os.Getgid()),
|
Gid: task.gid,
|
||||||
Uid: uint32(os.Getuid()),
|
Uid: task.uid,
|
||||||
FileSize: uint64(task.fileSize),
|
FileSize: uint64(task.fileSize),
|
||||||
FileMode: uint32(task.fileMode),
|
FileMode: uint32(task.fileMode),
|
||||||
Mime: mimeType,
|
Mime: mimeType,
|
||||||
@ -361,8 +367,8 @@ func (worker *FileCopyWorker) uploadFileInChunks(ctx context.Context, task FileC
|
|||||||
Attributes: &filer_pb.FuseAttributes{
|
Attributes: &filer_pb.FuseAttributes{
|
||||||
Crtime: time.Now().Unix(),
|
Crtime: time.Now().Unix(),
|
||||||
Mtime: time.Now().Unix(),
|
Mtime: time.Now().Unix(),
|
||||||
Gid: uint32(os.Getgid()),
|
Gid: task.gid,
|
||||||
Uid: uint32(os.Getuid()),
|
Uid: task.uid,
|
||||||
FileSize: uint64(task.fileSize),
|
FileSize: uint64(task.fileSize),
|
||||||
FileMode: uint32(task.fileMode),
|
FileMode: uint32(task.fileMode),
|
||||||
Mime: mimeType,
|
Mime: mimeType,
|
||||||
|
12
weed/util/file_util_non_posix.go
Normal file
12
weed/util/file_util_non_posix.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// +build linux darwin freebsd netbsd openbsd plan9 solaris zos
|
||||||
|
|
||||||
|
package util
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetFileUidGid(fi os.FileInfo) (uid, gid uint32) {
|
||||||
|
return fi.Sys().(*syscall.Stat_t).Uid, fi.Sys().(*syscall.Stat_t).Gid
|
||||||
|
}
|
11
weed/util/file_util_posix.go
Normal file
11
weed/util/file_util_posix.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// +build windows
|
||||||
|
|
||||||
|
package util
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetFileUidGid(fi os.FileInfo) (uid, gid uint32) {
|
||||||
|
return 0, 0
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user