forked from TrueCloudLab/rclone
cmount: Wait for mountpoint to appear on Windows before declaring mounted
This commit is contained in:
parent
e6ffe3464c
commit
204a19e67f
2 changed files with 17 additions and 5 deletions
|
@ -227,7 +227,7 @@ func mountOptions(device string, mountpoint string) (options []string) {
|
||||||
func mount(f fs.Fs, mountpoint string) (*mountlib.FS, <-chan error, func() error, error) {
|
func mount(f fs.Fs, mountpoint string) (*mountlib.FS, <-chan error, func() error, error) {
|
||||||
fs.Debugf(f, "Mounting on %q", mountpoint)
|
fs.Debugf(f, "Mounting on %q", mountpoint)
|
||||||
|
|
||||||
// Check the mountpoint
|
// Check the mountpoint - in Windows the mountpoint musn't exist before the mount
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
fi, err := os.Stat(mountpoint)
|
fi, err := os.Stat(mountpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -278,6 +278,22 @@ func mount(f fs.Fs, mountpoint string) (*mountlib.FS, <-chan error, func() error
|
||||||
case <-fsys.ready:
|
case <-fsys.ready:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wait for the mount point to be available on Windows
|
||||||
|
// On Windows the Init signal comes slightly before the mount is ready
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
const totalWait = 10 * time.Second
|
||||||
|
const individualWait = 10 * time.Millisecond
|
||||||
|
for i := 0; i < int(totalWait/individualWait); i++ {
|
||||||
|
_, err := os.Stat(mountpoint)
|
||||||
|
if err == nil {
|
||||||
|
goto found
|
||||||
|
}
|
||||||
|
time.Sleep(10 * time.Millisecond)
|
||||||
|
}
|
||||||
|
fs.Errorf(nil, "mountpoint %q didn't became available after %v - continuing anyway", mountpoint, totalWait)
|
||||||
|
found:
|
||||||
|
}
|
||||||
|
|
||||||
return fsys.FS, errChan, unmount, nil
|
return fsys.FS, errChan, unmount, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/ncw/rclone/cmd/mountlib"
|
"github.com/ncw/rclone/cmd/mountlib"
|
||||||
"github.com/ncw/rclone/fs"
|
"github.com/ncw/rclone/fs"
|
||||||
|
@ -141,9 +140,6 @@ func (r *Run) mount() {
|
||||||
r.skip = true
|
r.skip = true
|
||||||
}
|
}
|
||||||
log.Printf("mount OK")
|
log.Printf("mount OK")
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
time.Sleep(time.Second) // FIXME remove this when https://github.com/billziss-gh/cgofuse/issues/11 is fixed
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Run) umount() {
|
func (r *Run) umount() {
|
||||||
|
|
Loading…
Reference in a new issue