1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-04 09:33:36 +00:00

operations: Fix Purge and Rmdirs when dir is not empty

Before this change, Purge on the fallback path would try to delete
directories starting from the root rather than the dir passed in.
Rmdirs would also attempt to delete the root.
This commit is contained in:
Nick Craig-Wood
2018-10-26 23:47:23 +01:00
parent f7c31cd210
commit 948a5d25c2
2 changed files with 96 additions and 2 deletions

View File

@@ -975,7 +975,7 @@ func Purge(f fs.Fs, dir string) error {
if err != nil {
return err
}
err = Rmdirs(f, "", false)
err = Rmdirs(f, dir, false)
}
if err != nil {
fs.CountError(err)
@@ -1206,7 +1206,7 @@ func PublicLink(f fs.Fs, remote string) (string, error) {
// containing empty directories) under f, including f.
func Rmdirs(f fs.Fs, dir string, leaveRoot bool) error {
dirEmpty := make(map[string]bool)
dirEmpty[""] = !leaveRoot
dirEmpty[dir] = !leaveRoot
err := walk.Walk(f, dir, true, fs.Config.MaxDepth, func(dirPath string, entries fs.DirEntries, err error) error {
if err != nil {
fs.CountError(err)