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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
8 additions and
0 deletions
-
weed/command/mount_std.go
-
weed/mount/weedfs.go
|
@ -284,5 +284,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool { |
|
|
|
|
|
|
|
|
server.Serve() |
|
|
server.Serve() |
|
|
|
|
|
|
|
|
|
|
|
seaweedFileSystem.ClearCacheDir() |
|
|
|
|
|
|
|
|
return true |
|
|
return true |
|
|
} |
|
|
} |
|
@ -224,6 +224,12 @@ func (wfs *WFS) getCurrentFiler() pb.ServerAddress { |
|
|
return wfs.option.FilerAddresses[i] |
|
|
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() { |
|
|
func (option *Option) setupUniqueCacheDirectory() { |
|
|
cacheUniqueId := util.Md5String([]byte(option.MountDirectory + string(option.FilerAddresses[0]) + option.FilerMountRootPath + util.Version()))[0:8] |
|
|
cacheUniqueId := util.Md5String([]byte(option.MountDirectory + string(option.FilerAddresses[0]) + option.FilerMountRootPath + util.Version()))[0:8] |
|
|
option.uniqueCacheDirForRead = path.Join(option.CacheDirForRead, cacheUniqueId) |
|
|
option.uniqueCacheDirForRead = path.Join(option.CacheDirForRead, cacheUniqueId) |
|
|