Browse Source

clear cache directory when mount exits (#6605)

Signed-off-by: lizhengui <lizhengui@virtaitech.com>
Co-authored-by: lizhengui <lizhengui@virtaitech.com>
pull/3961/merge
lizhengui007 4 days ago
committed by GitHub
parent
commit
61249d8dde
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      weed/command/mount_std.go
  2. 6
      weed/mount/weedfs.go

2
weed/command/mount_std.go

@ -284,5 +284,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
server.Serve()
seaweedFileSystem.ClearCacheDir()
return true
}

6
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)

Loading…
Cancel
Save