"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
mountlib: make more useful as a general purpose file system adaptor
Nick Craig-Wood54950d342317
diff --git a/cmd/mountlib/errors.go b/cmd/mountlib/errors.goindex 6c00e78cc..1cd20a19f 100644--- a/cmd/mountlib/errors.go+++ b/cmd/mountlib/errors.go@@ -7,7 +7,7 @@ import "fmt"// Error describes low level errors in a cross platform waytype Error byte-// NB if changing errors translateError in cmd/mount/fs.go, cmd/cmount/fs.go+// NB if changing errors translateError in cmd/mount/fs.go, cmd/cmount/fs.go, cmd/serve/webdav/webdav.go// Low level errorsconst (diff --git a/cmd/mountlib/mount.go b/cmd/mountlib/mount.goindex a78e88916..a57c482d1 100644--- a/cmd/mountlib/mount.go+++ b/cmd/mountlib/mount.go@@ -9,6 +9,7 @@ import ("github.com/ncw/rclone/cmd""github.com/ncw/rclone/fs""github.com/spf13/cobra"+ "github.com/spf13/pflag")// Options set by command line flags@@ -170,14 +171,8 @@ like this:// Add flagsflags := commandDefintion.Flags()- flags.BoolVarP(&NoModTime, "no-modtime", "", NoModTime, "Don't read/write the modification time (can speed things up).")- flags.BoolVarP(&NoChecksum, "no-checksum", "", NoChecksum, "Don't compare checksums on up/download.")flags.BoolVarP(&DebugFUSE, "debug-fuse", "", DebugFUSE, "Debug the FUSE internals - needs -v.")- flags.BoolVarP(&NoSeek, "no-seek", "", NoSeek, "Don't allow seeking in files.")- flags.DurationVarP(&DirCacheTime, "dir-cache-time", "", DirCacheTime, "Time to cache directory entries for.")- flags.DurationVarP(&PollInterval, "poll-interval", "", PollInterval, "Time to wait between polling for changes. Must be smaller than dir-cache-time. Only on supported remotes. Set to 0 to disable.")// mount options- flags.BoolVarP(&ReadOnly, "read-only", "", ReadOnly, "Mount read-only.")flags.BoolVarP(&AllowNonEmpty, "allow-non-empty", "", AllowNonEmpty, "Allow mounting over a non-empty directory.")flags.BoolVarP(&AllowRoot, "allow-root", "", AllowRoot, "Allow access to root user.")flags.BoolVarP(&AllowOther, "allow-other", "", AllowOther, "Allow access to other users.")@@ -188,6 +183,19 @@ like this:ExtraFlags = flags.StringArrayP("fuse-flag", "", []string{}, "Flags or arguments to be passed direct to libfuse/WinFsp. Repeat if required.")//flags.BoolVarP(&foreground, "foreground", "", foreground, "Do not detach.")- platformFlags(flags)+ // Add in the generic flags+ AddFlags(flags)+return commandDefintion}++// AddFlags adds the non filing system specific flags to the command+func AddFlags(flags *pflag.FlagSet) {+ flags.BoolVarP(&NoModTime, "no-modtime", "", NoModTime, "Don't read/write the modification time (can speed things up).")+ flags.BoolVarP(&NoChecksum, "no-checksum", "", NoChecksum, "Don't compare checksums on up/download.")+ flags.BoolVarP(&NoSeek, "no-seek", "", NoSeek, "Don't allow seeking in files.")+ flags.DurationVarP(&DirCacheTime, "dir-cache-time", "", DirCacheTime, "Time to cache directory entries for.")+ flags.DurationVarP(&PollInterval, "poll-interval", "", PollInterval, "Time to wait between polling for changes. Must be smaller than dir-cache-time. Only on supported remotes. Set to 0 to disable.")+ flags.BoolVarP(&ReadOnly, "read-only", "", ReadOnly, "Mount read-only.")+ platformFlags(flags)+}diff --git a/cmd/mountlib/read.go b/cmd/mountlib/read.goindex 6019b1b18..fd7cf5408 100644--- a/cmd/mountlib/read.go+++ b/cmd/mountlib/read.go@@ -271,3 +271,18 @@ func (fh *ReadFileHandle) Release() error {}return err}++// Size returns the size of the underlying file+func (fh *ReadFileHandle) Size() int64 {+ return fh.o.Size()+}++// Close closes the file calling Flush then Release+func (fh *ReadFileHandle) Close() error {+ err := fh.Flush()+ err2 := fh.Release()+ if err != nil {+ return err+ }+ return err2+}diff --git a/cmd/mountlib/write.go b/cmd/mountlib/write.goindex a273c06ff..f17b3c6ca 100644--- a/cmd/mountlib/write.go+++ b/cmd/mountlib/write.go@@ -165,3 +165,13 @@ func (fh *WriteFileHandle) Release() error {}return err}++// Close closes the file calling Flush then Release+func (fh *WriteFileHandle) Close() error {+ err := fh.Flush()+ err2 := fh.Release()+ if err != nil {+ return err+ }+ return err2+}