Skip to content

Commit

Permalink
Fixed issue when deleting a file that was not owned.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Arkaeriit committed Jul 7, 2022
1 parent a9d25c8 commit 7afd3f4
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions rem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7afd3f4

Please sign in to comment.