clean trashed directories correctly
This commit is contained in:
parent
6794b3a9b2
commit
3e3b97b2c1
|
@ -149,7 +149,14 @@ func Remove(files []Info) (removed int, err error) {
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
log.Infof("removing %s permanently forever!!!", file.name)
|
log.Infof("removing %s permanently forever!!!", file.name)
|
||||||
if err = os.Remove(file.path); err != nil {
|
if err = os.Remove(file.path); err != nil {
|
||||||
return removed, err
|
if i, e := os.Stat(file.path); e == nil && i.IsDir() {
|
||||||
|
err = os.RemoveAll(file.path)
|
||||||
|
if err != nil {
|
||||||
|
return removed, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return removed, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err = os.Remove(file.trashinfo); err != nil {
|
if err = os.Remove(file.trashinfo); err != nil {
|
||||||
return removed, err
|
return removed, err
|
||||||
|
|
Loading…
Reference in a new issue