"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
fs/cache: add ClearConfig method to clear all remotes based on Config #4811
Nick Craig-Wooda10fbf16ea32
diff --git a/fs/cache/cache.go b/fs/cache/cache.goindex 961dd3c7d..e86bd0ec8 100644--- a/fs/cache/cache.go+++ b/fs/cache/cache.go@@ -124,6 +124,13 @@ func Put(fsString string, f fs.Fs) {addMapping(fsString, canonicalName)}+// ClearConfig deletes all entries which were based on the config name passed in+//+// Returns number of entries deleted+func ClearConfig(name string) (deleted int) {+ return c.DeletePrefix(name + ":")+}+// Clear removes everything from the cachefunc Clear() {c.Clear()diff --git a/fs/cache/cache_test.go b/fs/cache/cache_test.goindex 8f35ebd89..c23739588 100644--- a/fs/cache/cache_test.go+++ b/fs/cache/cache_test.go@@ -166,6 +166,22 @@ func TestPin(t *testing.T) {Unpin(f2)}+func TestClearConfig(t *testing.T) {+ cleanup, create := mockNewFs(t)+ defer cleanup()++ assert.Equal(t, 0, c.Entries())++ _, err := GetFn(context.Background(), "mock:/file.txt", create)+ require.Equal(t, fs.ErrorIsFile, err)++ assert.Equal(t, 2, Entries()) // file + parent++ assert.Equal(t, 2, ClearConfig("mock"))++ assert.Equal(t, 0, Entries())+}+func TestClear(t *testing.T) {cleanup, create := mockNewFs(t)defer cleanup()