diff --git a/cmd/cmount/mount.go b/cmd/cmount/mount.go index bb481e8fd..8c482b53a 100644 --- a/cmd/cmount/mount.go +++ b/cmd/cmount/mount.go @@ -129,6 +129,8 @@ func mount(f fs.Fs, mountpoint string) (*vfs.VFS, <-chan error, func() error, er // unmount unmount := func() error { + // Shutdown the VFS + fsys.VFS.Shutdown() fs.Debugf(nil, "Calling host.Unmount") if host.Unmount() { fs.Debugf(nil, "host.Unmount succeeded") diff --git a/cmd/mount/mount.go b/cmd/mount/mount.go index 3896fa3a7..4e4bb38df 100644 --- a/cmd/mount/mount.go +++ b/cmd/mount/mount.go @@ -100,6 +100,8 @@ func mount(f fs.Fs, mountpoint string) (*vfs.VFS, <-chan error, func() error, er } unmount := func() error { + // Shutdown the VFS + filesys.VFS.Shutdown() return fuse.Unmount(mountpoint) } diff --git a/cmd/mountlib/mounttest/fs.go b/cmd/mountlib/mounttest/fs.go index 60b43707d..8302baf60 100644 --- a/cmd/mountlib/mounttest/fs.go +++ b/cmd/mountlib/mounttest/fs.go @@ -19,6 +19,7 @@ import ( _ "github.com/ncw/rclone/fs/all" // import all the file systems "github.com/ncw/rclone/fstest" "github.com/ncw/rclone/vfs" + "github.com/ncw/rclone/vfs/vfsflags" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -38,9 +39,25 @@ var ( func TestMain(m *testing.M, fn MountFn) { mountFn = fn flag.Parse() - run = newRun() - rc := m.Run() - run.Finalise() + var rc int + cacheModes := []vfs.CacheMode{ + vfs.CacheModeOff, + vfs.CacheModeMinimal, + vfs.CacheModeWrites, + vfs.CacheModeFull, + } + for _, cacheMode := range cacheModes { + vfsflags.Opt.CacheMode = cacheMode + log.Printf("Starting test run with cache mode %v", cacheMode) + run = newRun() + rc = m.Run() + run.Finalise() + log.Printf("Finished test run with cache mode %v", cacheMode) + if rc != 0 { + break + } + } + vfsflags.Opt.CacheMode = vfs.DefaultOpt.CacheMode os.Exit(rc) } @@ -147,6 +164,12 @@ func (r *Run) umount() { if err != nil { log.Fatalf("umount failed: %v", err) } + + // Cleanup the VFS cache - umount has called Shutdown + err = r.vfs.CleanUp() + if err != nil { + log.Printf("Failed to cleanup the VFS cache: %v", err) + } } func (r *Run) skipIfNoFUSE(t *testing.T) {