diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-04-07 11:31:50 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-04-07 11:31:50 -0700 |
| commit | d14b614407a96e3d81bc655e5164d202c7e3b959 (patch) | |
| tree | 67887ff6d6e5ac78cb46546575a878a693303fd1 /weed/command | |
| parent | a32abda1a3fb696687739805faa1f5444d86c5fa (diff) | |
| download | seaweedfs-d14b614407a96e3d81bc655e5164d202c7e3b959.tar.xz seaweedfs-d14b614407a96e3d81bc655e5164d202c7e3b959.zip | |
weed filer.copy: use existing file owner and gropu id
Diffstat (limited to 'weed/command')
| -rw-r--r-- | weed/command/filer_copy.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/weed/command/filer_copy.go b/weed/command/filer_copy.go index 18b641ae5..777e52ab6 100644 --- a/weed/command/filer_copy.go +++ b/weed/command/filer_copy.go @@ -170,11 +170,15 @@ func genFileCopyTask(fileOrDir string, destPath string, fileCopyTaskChan chan Fi return nil } + uid, gid := util.GetFileUidGid(fi) + fileCopyTaskChan <- FileCopyTask{ sourceLocation: fileOrDir, destinationUrlPath: destPath, fileSize: fi.Size(), fileMode: fi.Mode(), + uid: uid, + gid: gid, } return nil @@ -200,6 +204,8 @@ type FileCopyTask struct { destinationUrlPath string fileSize int64 fileMode os.FileMode + uid uint32 + gid uint32 } 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{ Crtime: time.Now().Unix(), Mtime: time.Now().Unix(), - Gid: uint32(os.Getgid()), - Uid: uint32(os.Getuid()), + Gid: task.gid, + Uid: task.uid, FileSize: uint64(task.fileSize), FileMode: uint32(task.fileMode), Mime: mimeType, @@ -361,8 +367,8 @@ func (worker *FileCopyWorker) uploadFileInChunks(ctx context.Context, task FileC Attributes: &filer_pb.FuseAttributes{ Crtime: time.Now().Unix(), Mtime: time.Now().Unix(), - Gid: uint32(os.Getgid()), - Uid: uint32(os.Getuid()), + Gid: task.gid, + Uid: task.uid, FileSize: uint64(task.fileSize), FileMode: uint32(task.fileMode), Mime: mimeType, |
