mirror of
https://github.com/rclone/rclone.git
synced 2025-08-09 21:57:59 +02:00
mount: notice daemon dying much quicker
Before this change we waited until until the timeout to check the
daemon was alive.
Now we check it every 100ms like we do the mount status.
This also fixes compiling on all platforms which was broken by the
previous change
9bfbf2a4a
mount: fix macOS not noticing errors with --daemon
See: https://forum.rclone.org/t/rclone-mount-daemon-exits-successfully-even-when-mount-fails/43146
This commit is contained in:
@ -7,15 +7,10 @@ import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/moby/sys/mountinfo"
|
||||
)
|
||||
|
||||
const (
|
||||
pollInterval = 100 * time.Millisecond
|
||||
)
|
||||
|
||||
// CheckMountEmpty checks if folder is not already a mountpoint.
|
||||
// On Linux we use the OS-specific /proc/self/mountinfo API so the check won't access the path.
|
||||
// Directories marked as "mounted" by autofs are considered not mounted.
|
||||
@ -80,19 +75,5 @@ func CheckMountReady(mountpoint string) error {
|
||||
return fmt.Errorf(msg, mountpointAbs)
|
||||
}
|
||||
|
||||
// WaitMountReady waits until mountpoint is mounted by rclone.
|
||||
func WaitMountReady(mountpoint string, timeout time.Duration) (err error) {
|
||||
endTime := time.Now().Add(timeout)
|
||||
for {
|
||||
err = CheckMountReady(mountpoint)
|
||||
delay := time.Until(endTime)
|
||||
if err == nil || delay <= 0 {
|
||||
break
|
||||
}
|
||||
if delay > pollInterval {
|
||||
delay = pollInterval
|
||||
}
|
||||
time.Sleep(delay)
|
||||
}
|
||||
return
|
||||
}
|
||||
// CanCheckMountReady is set if CheckMountReady is functional
|
||||
var CanCheckMountReady = true
|
||||
|
Reference in New Issue
Block a user