"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: Document that Purger returns error on empty directory, test and fix
Nick Craig-Wood2f9f9afac25f
diff --git a/fs/fs.go b/fs/fs.goindex b53507f3d..6382a4b07 100644--- a/fs/fs.go+++ b/fs/fs.go@@ -85,7 +85,7 @@ type Fs interface {// Remove the directory (container, bucket) if empty//- // Return an error if it doesn't exists or isn't empty+ // Return an error if it doesn't exist or isn't emptyRmdir() error// Precision of the ModTimes in this Fs@@ -135,6 +135,8 @@ type Purger interface {//// Implement this if you have a way of deleting all the files// quicker than just running Remove() on the result of List()+ //+ // Return an error if it doesn't existPurge() error}diff --git a/fstest/fstest.go b/fstest/fstest.goindex e103b7648..2e35036e2 100644--- a/fstest/fstest.go+++ b/fstest/fstest.go@@ -161,9 +161,12 @@ func RandomRemote(remoteName string, subdir bool) (fs.Fs, func()) {}finalise := func() {- TestPurge(remote)+ _ = fs.Purge(remote) // ignore errorif parentRemote != nil {- TestPurge(parentRemote)+ err = fs.Purge(parentRemote) // ignore error+ if err != nil {+ log.Printf("Failed to purge %v: %v", parentRemote, err)+ }}// Delete directory if we made one aboveif rmdir != "" {diff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.goindex 99be49c6f..b7d3ca337 100644--- a/fstest/fstests/fstests.go+++ b/fstest/fstests/fstests.go@@ -322,7 +322,10 @@ func TestObjectRemove(t *testing.T) {func TestObjectPurge(t *testing.T) {skipIfNotOk(t)fstest.TestPurge(remote)- fstest.TestPurge(remote)+ err := fs.Purge(remote)+ if err == nil {+ t.Fatal("Expecting error after on second purge")+ }}func TestFinalise(t *testing.T) {diff --git a/local/local.go b/local/local.goindex 0b48889c0..e957e332e 100644--- a/local/local.go+++ b/local/local.go@@ -261,6 +261,13 @@ func (f *FsLocal) readPrecision() (precision time.Duration) {// deleting all the files quicker than just running Remove() on the// result of List()func (f *FsLocal) Purge() error {+ fi, err := os.Lstat(f.root)+ if err != nil {+ return err+ }+ if !fi.Mode().IsDir() {+ return fmt.Errorf("Can't Purge non directory: %q", f.root)+ }return os.RemoveAll(f.root)}