"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
Look for Fs in the cache rather than calling NewFs directly
Nick Craig-Wood8ee6034b2323
diff --git a/backend/cache/cache.go b/backend/cache/cache.goindex 708b41fc8..4bd27deed 100644--- a/backend/cache/cache.go+++ b/backend/cache/cache.go@@ -20,6 +20,7 @@ import ("github.com/ncw/rclone/backend/crypt""github.com/ncw/rclone/fs"+ "github.com/ncw/rclone/fs/cache""github.com/ncw/rclone/fs/config""github.com/ncw/rclone/fs/config/configmap""github.com/ncw/rclone/fs/config/configstruct"@@ -481,7 +482,7 @@ func NewFs(name, rootPath string, m configmap.Mapper) (fs.Fs, error) {return nil, errors.Wrapf(err, "failed to create cache directory %v", f.opt.TempWritePath)}f.opt.TempWritePath = filepath.ToSlash(f.opt.TempWritePath)- f.tempFs, err = fs.NewFs(f.opt.TempWritePath)+ f.tempFs, err = cache.Get(f.opt.TempWritePath)if err != nil {return nil, errors.Wrapf(err, "failed to create temp fs: %v", err)}diff --git a/backend/union/union.go b/backend/union/union.goindex bca6a0b78..8fcd3361d 100644--- a/backend/union/union.go+++ b/backend/union/union.go@@ -9,6 +9,7 @@ import ("time""github.com/ncw/rclone/fs"+ "github.com/ncw/rclone/fs/cache""github.com/ncw/rclone/fs/config/configmap""github.com/ncw/rclone/fs/config/configstruct""github.com/ncw/rclone/fs/hash"@@ -342,7 +343,7 @@ func NewFs(name, root string, m configmap.Mapper) (fs.Fs, error) {if configName != "local" {rootString = configName + ":" + rootString}- myFs, err := fs.NewFs(rootString)+ myFs, err := cache.Get(rootString)if err != nil {if err == fs.ErrorIsFile {return myFs, errdiff --git a/cmd/cmd.go b/cmd/cmd.goindex 439c68ef3..ab8ecc5b2 100644--- a/cmd/cmd.go+++ b/cmd/cmd.go@@ -22,6 +22,7 @@ import ("github.com/ncw/rclone/fs""github.com/ncw/rclone/fs/accounting"+ "github.com/ncw/rclone/fs/cache""github.com/ncw/rclone/fs/config/configflags""github.com/ncw/rclone/fs/config/flags""github.com/ncw/rclone/fs/filter"@@ -83,7 +84,7 @@ func NewFsFile(remote string) (fs.Fs, string) {fs.CountError(err)log.Fatalf("Failed to create file system for %q: %v", remote, err)}- f, err := fs.NewFs(remote)+ f, err := cache.Get(remote)switch err {case fs.ErrorIsFile:return f, path.Base(fsPath)@@ -131,7 +132,7 @@ func NewFsSrc(args []string) fs.Fs {//// This must point to a directoryfunc newFsDir(remote string) fs.Fs {- f, err := fs.NewFs(remote)+ f, err := cache.Get(remote)if err != nil {fs.CountError(err)log.Fatalf("Failed to create file system for %q: %v", remote, err)@@ -180,7 +181,7 @@ func NewFsSrcDstFiles(args []string) (fsrc fs.Fs, srcFileName string, fdst fs.Fslog.Fatalf("%q is a directory", args[1])}}- fdst, err := fs.NewFs(dstRemote)+ fdst, err := cache.Get(dstRemote)switch err {case fs.ErrorIsFile:fs.CountError(err)diff --git a/fs/sync/sync.go b/fs/sync/sync.goindex 122a03335..2970efa37 100644--- a/fs/sync/sync.go+++ b/fs/sync/sync.go@@ -10,6 +10,7 @@ import ("github.com/ncw/rclone/fs""github.com/ncw/rclone/fs/accounting"+ "github.com/ncw/rclone/fs/cache""github.com/ncw/rclone/fs/filter""github.com/ncw/rclone/fs/fserrors""github.com/ncw/rclone/fs/hash"@@ -123,7 +124,7 @@ func newSyncCopyMove(fdst, fsrc fs.Fs, deleteMode fs.DeleteMode, DoMove bool, de// Make Fs for --backup-dir if requiredif fs.Config.BackupDir != "" {var err error- s.backupDir, err = fs.NewFs(fs.Config.BackupDir)+ s.backupDir, err = cache.Get(fs.Config.BackupDir)if err != nil {return nil, fserrors.FatalError(errors.Errorf("Failed to make fs for --backup-dir %q: %v", fs.Config.BackupDir, err))}diff --git a/vfs/cache.go b/vfs/cache.goindex 1bab888fb..d4bdffd4f 100644--- a/vfs/cache.go+++ b/vfs/cache.go@@ -16,6 +16,7 @@ import ("github.com/djherbis/times""github.com/ncw/rclone/fs"+ fscache "github.com/ncw/rclone/fs/cache""github.com/ncw/rclone/fs/config""github.com/pkg/errors")@@ -100,7 +101,7 @@ func newCache(ctx context.Context, f fs.Fs, opt *Options) (*cache, error) {root := filepath.Join(config.CacheDir, "vfs", f.Name(), fRoot)fs.Debugf(nil, "vfs cache root is %q", root)- f, err := fs.NewFs(root)+ f, err := fscache.Get(root)if err != nil {return nil, errors.Wrap(err, "failed to create cache remote")}