mirror of
https://github.com/rclone/rclone.git
synced 2025-12-24 04:04:37 +00:00
vfs: fix SIGHUP killing serve instead of flushing directory caches
Before, rclone serve would crash when sent a SIGHUP which contradicts the documentation - saying it should flush the directory caches. Moved signal handling from the mount into the vfs layer, which now handles SIGHUP on all uses of the VFS including mount and serve. Fixes #8607
This commit is contained in:
@@ -403,27 +403,7 @@ func (m *MountPoint) Wait() error {
|
||||
fnHandle := atexit.Register(finalise)
|
||||
defer atexit.Unregister(fnHandle)
|
||||
|
||||
// Reload VFS cache on SIGHUP
|
||||
sigHup := make(chan os.Signal, 1)
|
||||
NotifyOnSigHup(sigHup)
|
||||
var err error
|
||||
|
||||
waiting := true
|
||||
for waiting {
|
||||
select {
|
||||
// umount triggered outside the app
|
||||
case err = <-m.ErrChan:
|
||||
waiting = false
|
||||
// user sent SIGHUP to clear the cache
|
||||
case <-sigHup:
|
||||
root, err := m.VFS.Root()
|
||||
if err != nil {
|
||||
fs.Errorf(m.VFS.Fs(), "Error reading root: %v", err)
|
||||
} else {
|
||||
root.ForgetAll()
|
||||
}
|
||||
}
|
||||
}
|
||||
err := <-m.ErrChan
|
||||
|
||||
finalise()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user