fix(ftp): remove dir (#1082)

This commit is contained in:
Xhofe 2022-05-13 17:38:22 +08:00
parent 79c9b6ac77
commit 87e339850d

View File

@ -227,13 +227,21 @@ func (driver FTP) Copy(src string, dst string, account *model.Account) error {
func (driver FTP) Delete(path string, account *model.Account) error {
path = utils.ParsePath(path)
file, err := driver.File(path, account)
if err != nil {
return err
}
realPath := utils.Join(account.RootFolder, path)
conn, err := driver.Login(account)
if err != nil {
return err
}
//defer func() { _ = conn.Quit() }()
err = conn.Delete(realPath)
if file.IsDir() {
err = conn.RemoveDirRecur(realPath)
} else {
err = conn.Delete(realPath)
}
return err
}