diff --git a/fs/fs.go b/fs/fs.go index 1d755ba62..a8c55775b 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -25,6 +25,7 @@ var ( fsRegistry []*Info // ErrorNotFoundInConfigFile is returned by NewFs if not found in config file ErrorNotFoundInConfigFile = fmt.Errorf("Didn't find section in config file") + ErrorCantPurge = fmt.Errorf("Can't purge directory") ErrorCantCopy = fmt.Errorf("Can't copy object - incompatible remotes") ErrorCantMove = fmt.Errorf("Can't copy object - incompatible remotes") ErrorCantDirMove = fmt.Errorf("Can't copy directory - incompatible remotes") diff --git a/fs/operations.go b/fs/operations.go index be62b1ea7..22fda131b 100644 --- a/fs/operations.go +++ b/fs/operations.go @@ -734,14 +734,20 @@ func Rmdir(f Fs) error { // // FIXME doesn't delete local directories func Purge(f Fs) error { + doFallbackPurge := true var err error if purger, ok := f.(Purger); ok { + doFallbackPurge = false if Config.DryRun { Debug(f, "Not purging as --dry-run set") } else { err = purger.Purge() + if err == ErrorCantPurge { + doFallbackPurge = true + } } - } else { + } + if doFallbackPurge { // DeleteFiles and Rmdir observe --dry-run DeleteFiles(f.List()) err = Rmdir(f)