1
0
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:
dougal
2025-09-01 12:14:57 +01:00
committed by Nick Craig-Wood
parent 9e200531b1
commit a4962e21d1
5 changed files with 34 additions and 25 deletions

View File

@@ -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()