aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlizhengui007 <517925159@qq.com>2025-03-07 00:14:17 +0800
committerGitHub <noreply@github.com>2025-03-06 08:14:17 -0800
commit61249d8dde3761473633a5dc667248f8e5e2a69a (patch)
treeefa6c42d5dee85da866c7f5ce9aefac1803655fb
parent533b675ec821c663418154d1b097e4acc35fffef (diff)
downloadseaweedfs-61249d8dde3761473633a5dc667248f8e5e2a69a.tar.xz
seaweedfs-61249d8dde3761473633a5dc667248f8e5e2a69a.zip
clear cache directory when mount exits (#6605)
Signed-off-by: lizhengui <lizhengui@virtaitech.com> Co-authored-by: lizhengui <lizhengui@virtaitech.com>
-rw-r--r--weed/command/mount_std.go2
-rw-r--r--weed/mount/weedfs.go6
2 files changed, 8 insertions, 0 deletions
diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go
index e4209449a..f00daba8a 100644
--- a/weed/command/mount_std.go
+++ b/weed/command/mount_std.go
@@ -284,5 +284,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
server.Serve()
+ seaweedFileSystem.ClearCacheDir()
+
return true
}
diff --git a/weed/mount/weedfs.go b/weed/mount/weedfs.go
index 7b67a8f32..77ffb7e77 100644
--- a/weed/mount/weedfs.go
+++ b/weed/mount/weedfs.go
@@ -224,6 +224,12 @@ func (wfs *WFS) getCurrentFiler() pb.ServerAddress {
return wfs.option.FilerAddresses[i]
}
+func (wfs *WFS) ClearCacheDir() {
+ wfs.metaCache.Shutdown()
+ os.RemoveAll(wfs.option.getUniqueCacheDirForWrite())
+ os.RemoveAll(wfs.option.getUniqueCacheDirForRead())
+}
+
func (option *Option) setupUniqueCacheDirectory() {
cacheUniqueId := util.Md5String([]byte(option.MountDirectory + string(option.FilerAddresses[0]) + option.FilerMountRootPath + util.Version()))[0:8]
option.uniqueCacheDirForRead = path.Join(option.CacheDirForRead, cacheUniqueId)