From 97a504b0bb8c7902f3ee26e42146fc08de3eeafd Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 2 May 2020 01:11:53 -0700 Subject: [PATCH] fix possible directory deletion error --- weed/filesys/dir.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/weed/filesys/dir.go b/weed/filesys/dir.go index c3dab919c..e4260d56f 100644 --- a/weed/filesys/dir.go +++ b/weed/filesys/dir.go @@ -324,6 +324,10 @@ func (dir *Dir) removeOneFile(req *fuse.RemoveRequest) error { dir.wfs.cacheDelete(filePath) dir.wfs.fsNodeCache.DeleteFsNode(filePath) + if dir.wfs.option.AsyncMetaDataCaching { + dir.wfs.metaCache.DeleteEntry(context.Background(), filePath) + } + glog.V(3).Infof("remove file: %v", req) err = filer_pb.Remove(dir.wfs, dir.FullPath(), req.Name, false, false, false) if err != nil { @@ -331,10 +335,6 @@ func (dir *Dir) removeOneFile(req *fuse.RemoveRequest) error { return fuse.ENOENT } - if dir.wfs.option.AsyncMetaDataCaching { - dir.wfs.metaCache.DeleteEntry(context.Background(), filePath) - } - return nil } @@ -345,6 +345,10 @@ func (dir *Dir) removeFolder(req *fuse.RemoveRequest) error { dir.wfs.cacheDelete(t) dir.wfs.fsNodeCache.DeleteFsNode(t) + if dir.wfs.option.AsyncMetaDataCaching { + dir.wfs.metaCache.DeleteEntry(context.Background(), t) + } + glog.V(3).Infof("remove directory entry: %v", req) err := filer_pb.Remove(dir.wfs, dir.FullPath(), req.Name, true, false, false) if err != nil { @@ -352,10 +356,6 @@ func (dir *Dir) removeFolder(req *fuse.RemoveRequest) error { return fuse.ENOENT } - if dir.wfs.option.AsyncMetaDataCaching { - dir.wfs.metaCache.DeleteEntry(context.Background(), t) - } - return nil }