mirror of
https://github.com/rclone/rclone.git
synced 2025-01-22 22:28:47 +01:00
Make it so optional interface Purge can fail so it can be wrapped
This commit is contained in:
parent
e9dda25c60
commit
2c2cb84ca7
1
fs/fs.go
1
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")
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user