From d076f0e6a072f1b99505db78a2b27e36366bad1c Mon Sep 17 00:00:00 2001 From: Jim Ma Date: Wed, 3 Jul 2024 12:27:22 +0800 Subject: [PATCH 1/2] fix: file task uid gid Signed-off-by: Jim Ma --- client/daemon/rpcserver/rpcserver.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/client/daemon/rpcserver/rpcserver.go b/client/daemon/rpcserver/rpcserver.go index ef60851c3a4..cf32190f4ad 100644 --- a/client/daemon/rpcserver/rpcserver.go +++ b/client/daemon/rpcserver/rpcserver.go @@ -798,6 +798,16 @@ func (s *server) download(ctx context.Context, req *dfdaemonv1.DownRequest, stre log.Errorf("task %s/%s failed: %d/%s", p.PeerID, p.TaskID, p.State.Code, p.State.Msg) return dferrors.New(p.State.Code, p.State.Msg) } + if p.PeerTaskDone { + // update permission before send last result + if req.Uid != 0 && req.Gid != 0 { + log.Infof("change own to uid %d gid %d", req.Uid, req.Gid) + if err = os.Chown(req.Output, int(req.Uid), int(req.Gid)); err != nil { + log.Errorf("change own failed: %s", err) + return err + } + } + } err = stream.Send(&dfdaemonv1.DownResult{ TaskId: p.TaskID, PeerId: p.PeerID, @@ -813,13 +823,6 @@ func (s *server) download(ctx context.Context, req *dfdaemonv1.DownRequest, stre if p.PeerTaskDone { p.DoneCallback() log.Infof("task %s/%s done", p.PeerID, p.TaskID) - if req.Uid != 0 && req.Gid != 0 { - log.Infof("change own to uid %d gid %d", req.Uid, req.Gid) - if err = os.Chown(req.Output, int(req.Uid), int(req.Gid)); err != nil { - log.Errorf("change own failed: %s", err) - return err - } - } return nil } case <-ctx.Done(): From aaac56aa06cc66db4c4d55c549f1462d060c3b57 Mon Sep 17 00:00:00 2001 From: Jim Ma Date: Wed, 3 Jul 2024 14:43:58 +0800 Subject: [PATCH 2/2] chore: update log Signed-off-by: Jim Ma --- client/daemon/rpcserver/rpcserver.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/daemon/rpcserver/rpcserver.go b/client/daemon/rpcserver/rpcserver.go index cf32190f4ad..f7539e4c81c 100644 --- a/client/daemon/rpcserver/rpcserver.go +++ b/client/daemon/rpcserver/rpcserver.go @@ -801,9 +801,9 @@ func (s *server) download(ctx context.Context, req *dfdaemonv1.DownRequest, stre if p.PeerTaskDone { // update permission before send last result if req.Uid != 0 && req.Gid != 0 { - log.Infof("change own to uid %d gid %d", req.Uid, req.Gid) + log.Infof("change owner to uid %d gid %d", req.Uid, req.Gid) if err = os.Chown(req.Output, int(req.Uid), int(req.Gid)); err != nil { - log.Errorf("change own failed: %s", err) + log.Errorf("change owner failed: %s", err) return err } }