mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 17:57:44 +08:00
fstest: Fix removal of test folders/buckets
This commit is contained in:
parent
b96c73bee6
commit
a375992186
|
@ -443,19 +443,21 @@ func Purge(f fs.Fs) {
|
||||||
doFallbackPurge := true
|
doFallbackPurge := true
|
||||||
if doPurge := f.Features().Purge; doPurge != nil {
|
if doPurge := f.Features().Purge; doPurge != nil {
|
||||||
doFallbackPurge = false
|
doFallbackPurge = false
|
||||||
|
fs.Debugf(f, "Purge remote")
|
||||||
err = doPurge()
|
err = doPurge()
|
||||||
if err == fs.ErrorCantPurge {
|
if err == fs.ErrorCantPurge {
|
||||||
doFallbackPurge = true
|
doFallbackPurge = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if doFallbackPurge {
|
if doFallbackPurge {
|
||||||
var dirs []string
|
dirs := []string{""}
|
||||||
err = walk.Walk(f, "", true, -1, func(dirPath string, entries fs.DirEntries, err error) error {
|
err = walk.Walk(f, "", true, -1, func(dirPath string, entries fs.DirEntries, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("purge walk returned error: %v", err)
|
log.Printf("purge walk returned error: %v", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
entries.ForObject(func(obj fs.Object) {
|
entries.ForObject(func(obj fs.Object) {
|
||||||
|
fs.Debugf(f, "Purge object %q", obj.Remote())
|
||||||
err = obj.Remove()
|
err = obj.Remove()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("purge failed to remove %q: %v", obj.Remote(), err)
|
log.Printf("purge failed to remove %q: %v", obj.Remote(), err)
|
||||||
|
@ -469,6 +471,7 @@ func Purge(f fs.Fs) {
|
||||||
sort.Strings(dirs)
|
sort.Strings(dirs)
|
||||||
for i := len(dirs) - 1; i >= 0; i-- {
|
for i := len(dirs) - 1; i >= 0; i-- {
|
||||||
dir := dirs[i]
|
dir := dirs[i]
|
||||||
|
fs.Debugf(f, "Purge dir %q", dir)
|
||||||
err := f.Rmdir(dir)
|
err := f.Rmdir(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("purge failed to rmdir %q: %v", dir, err)
|
log.Printf("purge failed to rmdir %q: %v", dir, err)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user