"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
lib/bucket: shorten locking window where possible
Nick Craig-Woode339c9ff8f06
diff --git a/lib/bucket/bucket.go b/lib/bucket/bucket.goindex 45065c474..2ebc14d33 100644--- a/lib/bucket/bucket.go+++ b/lib/bucket/bucket.go@@ -78,16 +78,16 @@ type (//// If f returns an error we assume the bucket was not createdfunc (c *Cache) Create(bucket string, create CreateFn, exists ExistsFn) (err error) {- c.createMu.Lock()- defer c.createMu.Unlock()- c.mu.Lock()- defer c.mu.Unlock()-// if we are at the root, then it is OKif bucket == "" {return nil}+ c.createMu.Lock()+ defer c.createMu.Unlock()+ c.mu.Lock()+ defer c.mu.Unlock()+// if have exists fuction and bucket has been deleted, check// it still existsif created, ok := c.status[bucket]; ok && !created && exists != nil {@@ -124,16 +124,16 @@ func (c *Cache) Create(bucket string, create CreateFn, exists ExistsFn) (err err//// If the bucket has already been deleted it returns ErrAlreadyDeletedfunc (c *Cache) Remove(bucket string, f func() error) error {- c.removeMu.Lock()- defer c.removeMu.Unlock()- c.mu.Lock()- defer c.mu.Unlock()-// if we are at the root, then it is OKif bucket == "" {return nil}+ c.removeMu.Lock()+ defer c.removeMu.Unlock()+ c.mu.Lock()+ defer c.mu.Unlock()+// If bucket already deleted then it is OKif created, ok := c.status[bucket]; ok && !created {return ErrAlreadyDeleted