From 7afd3f48182f118cd57bf69d69a0b4b058479fee Mon Sep 17 00:00:00 2001 From: Maxime Bouillot Date: Thu, 7 Jul 2022 16:48:29 +0200 Subject: [PATCH] Fixed issue when deleting a file that was not owned. When a file was not owned, the chmod could not work. Nonetheless, the deletion was still possible so there was no need to raise an error. --- rem.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/rem.go b/rem.go index 5a7e758..ff8a8bf 100644 --- a/rem.go +++ b/rem.go @@ -328,11 +328,8 @@ func chooseDataDir() string { func permanentlyDeleteFile(fileName string) { err := os.Chmod(fileName, 0700) // If some files don't have the write permission, it is impossible to delete them - if err != nil { - if os.IsNotExist(err) { // If we try to empty an already emptied trash, we will try to remove a non-existent log file. This check ensure that no error are raised in this case - return - } - handleErr(err) + if os.IsNotExist(err) { // If we try to empty an already emptied trash, we will try to remove a non-existent log file. As the chmod is not critical, no error needs to be raised + return } i, _ := os.Stat(fileName) if i.IsDir() { // As the chmod is not recursive, we must manually crawl through the trash to chmod and remove all files by hand