From 5f59d43c889313b7ce29e41f1f44315886d78bbd Mon Sep 17 00:00:00 2001 From: Jiffs Maverick Date: Wed, 7 Dec 2022 17:47:40 +0200 Subject: [PATCH 1/2] [filer] Fix uri escape during renaming (#4039) --- weed/server/filer_ui/filer.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weed/server/filer_ui/filer.html b/weed/server/filer_ui/filer.html index ef9ef75fb..28425f180 100644 --- a/weed/server/filer_ui/filer.html +++ b/weed/server/filer_ui/filer.html @@ -337,7 +337,7 @@ } var url = basePath + encodeURIComponent(newName); var originPath = basePath + originName; - url += '?mv.from=' + originPath; + url += '?mv.from=' + encodeURIComponent(originPath); var xhr = new XMLHttpRequest(); xhr.open('POST', url, false); xhr.setRequestHeader('Content-Type', ''); From 549354e324038d027134babb5294b7c7e820a12b Mon Sep 17 00:00:00 2001 From: wusong <75450248+wusongANKANG@users.noreply.github.com> Date: Fri, 9 Dec 2022 02:50:57 +0800 Subject: [PATCH 2/2] Fix hardlink counting (#4042) Signed-off-by: wusong Signed-off-by: wusong Co-authored-by: wusong --- weed/filer/filerstore_wrapper.go | 23 +++++++++++++++-------- weed/mount/meta_cache/meta_cache.go | 4 +++- weed/server/filer_grpc_server_rename.go | 1 + 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/weed/filer/filerstore_wrapper.go b/weed/filer/filerstore_wrapper.go index 19dfeac96..0fac6a138 100644 --- a/weed/filer/filerstore_wrapper.go +++ b/weed/filer/filerstore_wrapper.go @@ -2,13 +2,14 @@ package filer import ( "context" - "github.com/seaweedfs/seaweedfs/weed/glog" - "github.com/viant/ptrie" "io" "math" "strings" "time" + "github.com/seaweedfs/seaweedfs/weed/glog" + "github.com/viant/ptrie" + "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/stats" "github.com/seaweedfs/seaweedfs/weed/util" @@ -186,9 +187,12 @@ func (fsw *FilerStoreWrapper) DeleteEntry(ctx context.Context, fp util.FullPath) } if len(existingEntry.HardLinkId) != 0 { // remove hard link - glog.V(4).Infof("DeleteHardLink %s", existingEntry.FullPath) - if err = fsw.DeleteHardLink(ctx, existingEntry.HardLinkId); err != nil { - return err + op := ctx.Value("OP") + if op != "MV" { + glog.V(4).Infof("DeleteHardLink %s", existingEntry.FullPath) + if err = fsw.DeleteHardLink(ctx, existingEntry.HardLinkId); err != nil { + return err + } } } @@ -206,9 +210,12 @@ func (fsw *FilerStoreWrapper) DeleteOneEntry(ctx context.Context, existingEntry if len(existingEntry.HardLinkId) != 0 { // remove hard link - glog.V(4).Infof("DeleteHardLink %s", existingEntry.FullPath) - if err = fsw.DeleteHardLink(ctx, existingEntry.HardLinkId); err != nil { - return err + op := ctx.Value("OP") + if op != "MV" { + glog.V(4).Infof("DeleteHardLink %s", existingEntry.FullPath) + if err = fsw.DeleteHardLink(ctx, existingEntry.HardLinkId); err != nil { + return err + } } } diff --git a/weed/mount/meta_cache/meta_cache.go b/weed/mount/meta_cache/meta_cache.go index 76def715b..cb2521824 100644 --- a/weed/mount/meta_cache/meta_cache.go +++ b/weed/mount/meta_cache/meta_cache.go @@ -2,12 +2,13 @@ package meta_cache import ( "context" + "os" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/filer/leveldb" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/util" - "os" ) // need to have logic similar to FilerStoreWrapper @@ -76,6 +77,7 @@ func (mc *MetaCache) AtomicUpdateEntryFromFiler(ctx context.Context, oldPath uti // skip the unnecessary deletion // leave the update to the following InsertEntry operation } else { + ctx = context.WithValue(ctx, "OP", "MV") glog.V(3).Infof("DeleteEntry %s", oldPath) if err := mc.localStore.DeleteEntry(ctx, oldPath); err != nil { return err diff --git a/weed/server/filer_grpc_server_rename.go b/weed/server/filer_grpc_server_rename.go index 8a3a8f07f..ff682da43 100644 --- a/weed/server/filer_grpc_server_rename.go +++ b/weed/server/filer_grpc_server_rename.go @@ -202,6 +202,7 @@ func (fs *FilerServer) moveSelfEntry(ctx context.Context, stream filer_pb.Seawee } // delete old entry + ctx = context.WithValue(ctx, "OP", "MV") deleteErr := fs.filer.DeleteEntryMetaAndData(ctx, oldPath, false, false, false, false, signatures) if deleteErr != nil { return deleteErr