"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
cache: Implement --cache-db-wait-time flag
Nick Craig-Wooda7dbf32c538d
diff --git a/backend/cache/cache.go b/backend/cache/cache.goindex d25e83892..a554ec316 100644--- a/backend/cache/cache.go+++ b/backend/cache/cache.go@@ -50,6 +50,8 @@ const (DefCacheWrites = false// DefCacheTmpWaitTime says how long should files be stored in local cache before being uploadedDefCacheTmpWaitTime = "15m"+ // DefCacheDbWaitTime defines how long the cache backend should wait for the DB to be available+ DefCacheDbWaitTime = 1 * time.Second)// Globals@@ -69,6 +71,7 @@ var (cacheStoreWrites = flags.BoolP("cache-writes", "", DefCacheWrites, "Will cache file data on writes through the FS")cacheTempWritePath = flags.StringP("cache-tmp-upload-path", "", "", "Directory to keep temporary files until they are uploaded to the cloud storage")cacheTempWaitTime = flags.StringP("cache-tmp-wait-time", "", DefCacheTmpWaitTime, "How long should files be stored in local cache before being uploaded")+ cacheDbWaitTime = flags.DurationP("cache-db-wait-time", "", DefCacheDbWaitTime, "How long to wait for the DB to be available - 0 is unlimited"))// Register with Fsdiff --git a/backend/cache/storage_persistent.go b/backend/cache/storage_persistent.goindex bbc77c2a4..894d79e92 100644--- a/backend/cache/storage_persistent.go+++ b/backend/cache/storage_persistent.go@@ -122,7 +122,7 @@ func (b *Persistent) connect() error {if err != nil {return errors.Wrapf(err, "failed to create a data directory %q", b.dataPath)}- b.db, err = bolt.Open(b.dbPath, 0644, &bolt.Options{Timeout: 1 * time.Second})+ b.db, err = bolt.Open(b.dbPath, 0644, &bolt.Options{Timeout: *cacheDbWaitTime})if err != nil {return errors.Wrapf(err, "failed to open a cache connection to %q", b.dbPath)}diff --git a/docs/content/cache.md b/docs/content/cache.mdindex 49cfc27a2..23a9d947c 100644--- a/docs/content/cache.md+++ b/docs/content/cache.md@@ -397,3 +397,13 @@ Note that only one file is uploaded at a time and it can take longer tostart the upload if a queue formed for this purpose.**Default**: 15m++#### --cache-db-wait-time=DURATION ####++Only one process can have the DB open at any one time, so rclone waits+for this duration for the DB to become available before it gives an+error.++If you set it to 0 then it will wait forever.++**Default**: 1s