mirror of
https://github.com/rclone/rclone
synced 2024-12-01 10:31:57 +01:00
cache: add SIGHUP support to evict all cache - fixes 1906
This commit is contained in:
parent
ebbe77f525
commit
8839e4ee33
15
cache/cache.go
vendored
15
cache/cache.go
vendored
@ -334,12 +334,17 @@ func NewFs(name, rpath string) (fs.Fs, error) {
|
||||
}
|
||||
// Trap SIGINT and SIGTERM to close the DB handle gracefully
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
|
||||
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
|
||||
go func() {
|
||||
s := <-c
|
||||
fs.Debugf(f, "Got signal: %v", s)
|
||||
if s == syscall.SIGINT || s == syscall.SIGTERM {
|
||||
f.cache.Close()
|
||||
for {
|
||||
s := <-c
|
||||
if s == syscall.SIGINT || s == syscall.SIGTERM {
|
||||
fs.Debugf(f, "Got signal: %v", s)
|
||||
f.cache.Close()
|
||||
} else if s == syscall.SIGHUP {
|
||||
fs.Infof(f, "Clearing cache from signal")
|
||||
f.DirCacheFlush()
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
5
cache/storage_persistent.go
vendored
5
cache/storage_persistent.go
vendored
@ -272,11 +272,12 @@ func (b *Persistent) RemoveDir(fp string) error {
|
||||
|
||||
// delete chunks on disk
|
||||
// safe to ignore as the files might not have been open
|
||||
if err != nil {
|
||||
if err == nil {
|
||||
_ = os.RemoveAll(path.Join(b.dataPath, fp))
|
||||
_ = os.MkdirAll(b.dataPath, os.ModePerm)
|
||||
}
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
// ExpireDir will flush a CachedDirectory and all its objects from the objects
|
||||
|
Loading…
Reference in New Issue
Block a user