mirror of
https://github.com/rclone/rclone.git
synced 2025-08-23 11:32:03 +02:00
fs: Add directory to optional Purge interface - fixes #1891
- add a directory to the optional Purge interface - fix up all the backends - add an additional integration test to test for the feature - use the new feature in operations.Purge Many of the backends had been prepared in advance for this so the change was trivial for them.
This commit is contained in:
@@ -921,20 +921,16 @@ func Rmdir(ctx context.Context, f fs.Fs, dir string) error {
|
||||
}
|
||||
|
||||
// Purge removes a directory and all of its contents
|
||||
func Purge(ctx context.Context, f fs.Fs, dir string) error {
|
||||
func Purge(ctx context.Context, f fs.Fs, dir string) (err error) {
|
||||
doFallbackPurge := true
|
||||
var err error
|
||||
if dir == "" {
|
||||
// FIXME change the Purge interface so it takes a dir - see #1891
|
||||
if doPurge := f.Features().Purge; doPurge != nil {
|
||||
doFallbackPurge = false
|
||||
if SkipDestructive(ctx, fs.LogDirName(f, dir), "purge directory") {
|
||||
return nil
|
||||
}
|
||||
err = doPurge(ctx)
|
||||
if err == fs.ErrorCantPurge {
|
||||
doFallbackPurge = true
|
||||
}
|
||||
if doPurge := f.Features().Purge; doPurge != nil {
|
||||
doFallbackPurge = false
|
||||
if SkipDestructive(ctx, fs.LogDirName(f, dir), "purge directory") {
|
||||
return nil
|
||||
}
|
||||
err = doPurge(ctx, dir)
|
||||
if err == fs.ErrorCantPurge {
|
||||
doFallbackPurge = true
|
||||
}
|
||||
}
|
||||
if doFallbackPurge {
|
||||
|
Reference in New Issue
Block a user