mirror of https://github.com/rclone/rclone.git
cache: Implement --cache-db-wait-time flag
This can be used to make the cache wait for other running cache backends to finish rather than erroring after 1 second.
This commit is contained in:
parent
6025bb6ad1
commit
a7dbf32c53
|
@ -50,6 +50,8 @@ const (
|
||||||
DefCacheWrites = false
|
DefCacheWrites = false
|
||||||
// DefCacheTmpWaitTime says how long should files be stored in local cache before being uploaded
|
// DefCacheTmpWaitTime says how long should files be stored in local cache before being uploaded
|
||||||
DefCacheTmpWaitTime = "15m"
|
DefCacheTmpWaitTime = "15m"
|
||||||
|
// DefCacheDbWaitTime defines how long the cache backend should wait for the DB to be available
|
||||||
|
DefCacheDbWaitTime = 1 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
|
@ -69,6 +71,7 @@ var (
|
||||||
cacheStoreWrites = flags.BoolP("cache-writes", "", DefCacheWrites, "Will cache file data on writes through the FS")
|
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")
|
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")
|
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 Fs
|
// Register with Fs
|
||||||
|
|
|
@ -122,7 +122,7 @@ func (b *Persistent) connect() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "failed to create a data directory %q", b.dataPath)
|
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 {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "failed to open a cache connection to %q", b.dbPath)
|
return errors.Wrapf(err, "failed to open a cache connection to %q", b.dbPath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -397,3 +397,13 @@ Note that only one file is uploaded at a time and it can take longer to
|
||||||
start the upload if a queue formed for this purpose.
|
start the upload if a queue formed for this purpose.
|
||||||
|
|
||||||
**Default**: 15m
|
**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
|
||||||
|
|
Loading…
Reference in New Issue