From 3e3b97b2c11b5bbdf3e0a599aa2293f508900860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Tue, 18 Jun 2024 16:56:03 -0700 Subject: [PATCH] clean trashed directories correctly --- internal/trash/trash.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/trash/trash.go b/internal/trash/trash.go index 92a03ca..0462fdc 100644 --- a/internal/trash/trash.go +++ b/internal/trash/trash.go @@ -149,7 +149,14 @@ func Remove(files []Info) (removed int, err error) { for _, file := range files { log.Infof("removing %s permanently forever!!!", file.name) 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 { return removed, err