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:
@@ -284,5 +284,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
|
||||
|
||||
server.Serve()
|
||||
|
||||
seaweedFileSystem.ClearCacheDir()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user