mirror of
https://github.com/rclone/rclone.git
synced 2024-11-26 10:25:03 +01:00
ftp: stop rmdir being recursive
This commit is contained in:
parent
3136a75f4d
commit
6cc783f20b
20
ftp/ftp.go
20
ftp/ftp.go
@ -414,27 +414,9 @@ func (f *Fs) Mkdir(dir string) (err error) {
|
||||
//
|
||||
// Return an error if it doesn't exist or isn't empty
|
||||
func (f *Fs) Rmdir(dir string) error {
|
||||
// This is actually a recursive remove directory
|
||||
c, err := f.getFtpConnection()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Rmdir")
|
||||
}
|
||||
files, err := c.List(path.Join(f.root, dir))
|
||||
f.putFtpConnection(&c)
|
||||
if err != nil {
|
||||
return translateErrorDir(err)
|
||||
}
|
||||
for _, file := range files {
|
||||
if file.Type == ftp.EntryTypeFolder && file.Name != "." && file.Name != ".." {
|
||||
err = f.Rmdir(path.Join(dir, file.Name))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "rmdir")
|
||||
}
|
||||
}
|
||||
}
|
||||
c, err = f.getFtpConnection()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Rmdir")
|
||||
return errors.Wrap(translateErrorFile(err), "Rmdir")
|
||||
}
|
||||
err = c.RemoveDir(path.Join(f.root, dir))
|
||||
f.putFtpConnection(&c)
|
||||
|
Loading…
Reference in New Issue
Block a user