clear cache directory when mount exits (#6605)

Signed-off-by: lizhengui <lizhengui@virtaitech.com>
Co-authored-by: lizhengui <lizhengui@virtaitech.com>
This commit is contained in:
lizhengui007andlizhengui authored and GitHub committed 2025-03-06 08:14:17 -08:00
1 parent 533b675ec8
commit 61249d8dde
2 files changed
+8

No files matched your search

+2
View File
@@ -284,5 +284,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
server.Serve()
seaweedFileSystem.ClearCacheDir()
return true
}
+6
View File
@@ -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)