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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user