From 8c073feed6b8860b089fbc9e8c120919faba538f Mon Sep 17 00:00:00 2001 From: tbs60 Date: Tue, 27 Aug 2024 17:15:37 +0800 Subject: [PATCH 1/2] fix: adjust file info from cache, issue: #287 --- .../pkg/client/bkcommondist_protocol.go | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/backend/booster/bk_dist/worker/pkg/client/bkcommondist_protocol.go b/src/backend/booster/bk_dist/worker/pkg/client/bkcommondist_protocol.go index d6104e1b..31c7f496 100644 --- a/src/backend/booster/bk_dist/worker/pkg/client/bkcommondist_protocol.go +++ b/src/backend/booster/bk_dist/worker/pkg/client/bkcommondist_protocol.go @@ -837,28 +837,29 @@ func encodeSendFileReq( } fullpath := sandbox.GetAbsPath(f.FilePath) + size := f.FileSize + md5 := f.Md5 + targetrelativepath := f.Targetrelativepath + filemode := f.Filemode + linkTarget := f.LinkTarget + modifytime := f.Lastmodifytime // TODO : fresh file info here, avoid file info changed - newlyInfo := dcFile.Lstat(fullpath) - if !newlyInfo.Exist() { - blog.Warnf("file %f not existed when encode send request", fullpath) - continue - } + if size > 0 { + newlyInfo := dcFile.Lstat(fullpath) + if !newlyInfo.Exist() { + blog.Warnf("file %f not existed when encode send request", fullpath) + continue + } - size := newlyInfo.Size() - md5 := "" - if f.Md5 != "" { - md5, _ = newlyInfo.Md5() + size = newlyInfo.Size() + md5 = "" + if f.Md5 != "" { + md5, _ = newlyInfo.Md5() + } + filemode = newlyInfo.Mode32() + modifytime = newlyInfo.ModifyTime64() } - filemode := newlyInfo.Mode32() - modifytime := newlyInfo.ModifyTime64() - - // size := f.FileSize - // md5 := f.Md5 - targetrelativepath := f.Targetrelativepath - // filemode := f.Filemode - linkTarget := f.LinkTarget - // modifytime := f.Lastmodifytime if size <= 0 { pbbody.Inputfiles = append(pbbody.Inputfiles, &protocol.PBFileDesc{ From 9ee420aa5afd4b040f9abd5487a5d29b1e95e964 Mon Sep 17 00:00:00 2001 From: tbs60 Date: Tue, 27 Aug 2024 17:33:12 +0800 Subject: [PATCH 2/2] fix: adjust file info from cache, issue: #287 --- .../bk_dist/worker/pkg/client/bkcommondist_protocol.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/booster/bk_dist/worker/pkg/client/bkcommondist_protocol.go b/src/backend/booster/bk_dist/worker/pkg/client/bkcommondist_protocol.go index 31c7f496..92dab9a1 100644 --- a/src/backend/booster/bk_dist/worker/pkg/client/bkcommondist_protocol.go +++ b/src/backend/booster/bk_dist/worker/pkg/client/bkcommondist_protocol.go @@ -846,7 +846,14 @@ func encodeSendFileReq( // TODO : fresh file info here, avoid file info changed if size > 0 { - newlyInfo := dcFile.Lstat(fullpath) + var newlyInfo *dcFile.Info + localdir := filepath.Dir(fullpath) + // 如果本地路径和远端不一样,则不能用Lstat + if localdir != targetrelativepath { + newlyInfo = dcFile.Stat(fullpath) + } else { + newlyInfo = dcFile.Lstat(fullpath) + } if !newlyInfo.Exist() { blog.Warnf("file %f not existed when encode send request", fullpath) continue