"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
test_all: optionally run Cleanup before cleaning a remote
Nick Craig-Wood9a5178be7ac2
diff --git a/fstest/test_all/clean.go b/fstest/test_all/clean.goindex 6622f839b..3eb40ca4d 100644--- a/fstest/test_all/clean.go+++ b/fstest/test_all/clean.go@@ -19,16 +19,24 @@ import (var MatchTestRemote = regexp.MustCompile(`^rclone-test-[abcdefghijklmnopqrstuvwxyz0123456789]{24}(_segments)?$`)// cleanFs runs a single clean fs for left over directories-func cleanFs(remote string) error {+func cleanFs(ctx context.Context, remote string, cleanup bool) error {f, err := fs.NewFs(remote)if err != nil {return err}- entries, err := list.DirSorted(context.Background(), f, true, "")+ var lastErr error+ if cleanup {+ log.Printf("%q - running cleanup", remote)+ err = operations.CleanUp(ctx, f)+ if err != nil {+ lastErr = err+ fs.Errorf(f, "Cleanup failed: %v", err)+ }+ }+ entries, err := list.DirSorted(ctx, f, true, "")if err != nil {return err}- var lastErr errorerr = entries.ForDirError(func(dir fs.Directory) error {dirPath := dir.Remote()fullPath := remote + dirPath@@ -45,7 +53,7 @@ func cleanFs(remote string) error {fs.Errorf(fullPath, "%v", err)return nil}- err = operations.Purge(context.Background(), dir, "")+ err = operations.Purge(ctx, dir, "")if err != nil {err = errors.Wrap(err, "Purge failed")lastErr = err@@ -62,11 +70,12 @@ func cleanFs(remote string) error {}// cleanRemotes cleans the list of remotes passed in-func cleanRemotes(remotes []string) error {+func cleanRemotes(conf *Config) error {var lastError error- for _, remote := range remotes {+ for _, backend := range conf.Backends {+ remote := backend.Remotelog.Printf("%q - Cleaning", remote)- err := cleanFs(remote)+ err := cleanFs(context.Background(), remote, backend.CleanUp)if err != nil {lastError = errlog.Printf("Failed to purge %q: %v", remote, err)diff --git a/fstest/test_all/config.go b/fstest/test_all/config.goindex 5724072c4..941c7caa5 100644--- a/fstest/test_all/config.go+++ b/fstest/test_all/config.go@@ -33,6 +33,7 @@ type Backend struct {Short bool // set to test with -shortOneOnly bool // set to run only one backend test at onceMaxFile string // file size limit+ CleanUp bool // when running clean, run cleanup firstIgnore []string // test names to ignore the failure ofTests []string // paths of tests to run, blank for all}@@ -184,16 +185,3 @@ func (c *Config) filterTests(paths []string) {}c.Tests = newTests}--// Remotes returns the unique remotes-func (c *Config) Remotes() (remotes []string) {- found := map[string]struct{}{}- for _, backend := range c.Backends {- if _, ok := found[backend.Remote]; ok {- continue- }- remotes = append(remotes, backend.Remote)- found[backend.Remote] = struct{}{}- }- return remotes-}diff --git a/fstest/test_all/config.yaml b/fstest/test_all/config.yamlindex 4ebebe210..9a4671cd2 100644--- a/fstest/test_all/config.yaml+++ b/fstest/test_all/config.yaml@@ -205,6 +205,7 @@ backends:remote: "TestQingStor:"fastlist: falseoneonly: true+ cleanup: true- backend: "azureblob"remote: "TestAzureBlob:"fastlist: truediff --git a/fstest/test_all/test_all.go b/fstest/test_all/test_all.goindex cb2ee0e18..f464e1182 100644--- a/fstest/test_all/test_all.go+++ b/fstest/test_all/test_all.go@@ -86,7 +86,7 @@ func main() {// Just clean the directories if requiredif *clean {- err := cleanRemotes(conf.Remotes())+ err := cleanRemotes(conf)if err != nil {log.Fatalf("Failed to clean: %v", err)}