"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: add --vfs-read-wait and --vfs-write-wait flags
Nick Craig-Wood393b94bb7004
diff --git a/vfs/read.go b/vfs/read.goindex 880314e5a..526467616 100644--- a/vfs/read.go+++ b/vfs/read.go@@ -232,9 +232,10 @@ func (fh *ReadFileHandle) readAt(p []byte, off int64) (n int, err error) {if gap := off - fh.offset; gap > 0 && gap < int64(8*maxBuf) {// Set a background timer so we don't wait for long// Waits here potentially affect all seeks so need to keep them short- // This time here was made by finding the smallest when mounting a local backend- // that didn't cause seeks.- const maxWait = 5 * time.Millisecond+ // The default time here was made by finding the+ // smallest when mounting a local backend that didn't+ // cause seeks.+ maxWait := fh.file.d.vfs.Opt.ReadWaittimeout := time.NewTimer(maxWait)done := make(chan struct{})abort := int32(0)diff --git a/vfs/vfs.go b/vfs/vfs.goindex 1bab8810a..58e7630b1 100644--- a/vfs/vfs.go+++ b/vfs/vfs.go@@ -53,6 +53,8 @@ var DefaultOpt = Options{ChunkSizeLimit: -1,CacheMaxSize: -1,CaseInsensitive: runtime.GOOS == "windows" || runtime.GOOS == "darwin", // default to true on Windows and Mac, false otherwise+ WriteWait: 1000 * time.Millisecond,+ ReadWait: 5 * time.Millisecond,}// Node represents either a directory (*Dir) or a file (*File)@@ -202,6 +204,8 @@ type Options struct {CacheMaxSize fs.SizeSuffixCachePollInterval time.DurationCaseInsensitive bool+ WriteWait time.Duration // time to wait for in-sequence write+ ReadWait time.Duration // time to wait for in-sequence read}// New creates a new VFS and root directory. If opt is nil, thendiff --git a/vfs/vfsflags/vfsflags.go b/vfs/vfsflags/vfsflags.goindex cf2e910ec..3c8703466 100644--- a/vfs/vfsflags/vfsflags.go+++ b/vfs/vfsflags/vfsflags.go@@ -33,5 +33,7 @@ func AddFlags(flagSet *pflag.FlagSet) {flags.FVarP(flagSet, DirPerms, "dir-perms", "", "Directory permissions")flags.FVarP(flagSet, FilePerms, "file-perms", "", "File permissions")flags.BoolVarP(flagSet, &Opt.CaseInsensitive, "vfs-case-insensitive", "", Opt.CaseInsensitive, "If a file name not found, find a case insensitive match.")+ flags.DurationVarP(flagSet, &Opt.WriteWait, "vfs-write-wait", "", Opt.WriteWait, "Time to wait for in-sequence write before giving error.")+ flags.DurationVarP(flagSet, &Opt.ReadWait, "vfs-read-wait", "", Opt.ReadWait, "Time to wait for in-sequence read before seeking.")platformFlags(flagSet)}diff --git a/vfs/write.go b/vfs/write.goindex 7939a4823..e45752360 100644--- a/vfs/write.go+++ b/vfs/write.go@@ -132,7 +132,8 @@ func (fh *WriteFileHandle) writeAt(p []byte, off int64) (n int, err error) {}if fh.offset != off {// Set a background timer so we don't wait forever- timeout := time.NewTimer(10 * time.Second)+ maxWait := fh.file.d.vfs.Opt.WriteWait+ timeout := time.NewTimer(maxWait)done := make(chan struct{})abort := int32(0)go func() {