"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
vfs: fix OS vs Unix path confusion - fixes ChangeNotify on Windows
Nick Craig-Wood50e31c6636bf
diff --git a/vfs/vfscache/vfscache.go b/vfs/vfscache/vfscache.goindex f08e7b1b9..fc4938f7e 100644--- a/vfs/vfscache/vfscache.go+++ b/vfs/vfscache/vfscache.go@@ -4,6 +4,7 @@ package vfscacheimport ("context""os"+ "path""path/filepath""runtime""sort"@@ -78,9 +79,11 @@ func New(ctx context.Context, fremote fs.Fs, opt *vfscommon.Options) (*Cache, er}// clean returns the cleaned version of name for use in the index map+//+// name should be a remote path not an osPathfunc clean(name string) string {name = strings.Trim(name, "/")- name = filepath.Clean(name)+ name = path.Clean(name)if name == "." || name == "/" {name = ""}@@ -94,9 +97,11 @@ func (c *Cache) ToOSPath(name string) string {// Mkdir makes the directory for name in the cache and returns an os// path for the file+//+// name should be a remote path not an osPathfunc (c *Cache) Mkdir(name string) (string, error) {parent := vfscommon.FindParent(name)- leaf := filepath.Base(name)+ leaf := path.Base(name)parentPath := c.ToOSPath(parent)err := os.MkdirAll(parentPath, 0700)if err != nil {@@ -244,7 +249,7 @@ func (c *Cache) Rename(name string, newName string) (err error) {if !os.IsNotExist(err) {return errors.Wrapf(err, "Failed to stat destination: %s", osNewPath)}- parent := vfscommon.FindParent(osNewPath)+ parent := vfscommon.OsFindParent(osNewPath)err = os.MkdirAll(parent, 0700)if err != nil {return errors.Wrapf(err, "Failed to create parent dir: %s", parent)diff --git a/vfs/vfscommon/path.go b/vfs/vfscommon/path.goindex 3e51ff4b9..77225df0f 100644--- a/vfs/vfscommon/path.go+++ b/vfs/vfscommon/path.go@@ -1,10 +1,24 @@package vfscommon-import "path/filepath"+import (+ "path"+ "path/filepath"+)++// OsFindParent returns the parent directory of name, or "" for the+// root for OS native paths.+func OsFindParent(name string) string {+ parent := filepath.Dir(name)+ if parent == "." || parent == "/" {+ parent = ""+ }+ return parent+}// FindParent returns the parent directory of name, or "" for the root+// for rclone paths.func FindParent(name string) string {- parent := filepath.Dir(name)+ parent := path.Dir(name)if parent == "." || parent == "/" {parent = ""}