andreafrancia / trash-cli

Command line interface to the freedesktop.org trashcan.
GNU General Public License v2.0
3.53k stars 177 forks source link

PermissionError in trash-empty incorrectly user's .Trash folder #343

Closed rysterzhu closed 3 months ago

rysterzhu commented 3 months ago

Describe the bug Traceback (most recent call last): File "/usr/local/bin/trash-empty", line 5, in sys.exit(main()) File "/usr/local/lib/python3.10/dist-packages/trashcli/empty/main.py", line 35, in main return empty_cmd.run_cmd(sys.argv[1:], os.environ, os.getuid()) File "/usr/local/lib/python3.10/dist-packages/trashcli/empty/empty_cmd.py", line 75, in run_cmd return self.empty_action.run_action(args) File "/usr/local/lib/python3.10/dist-packages/trashcli/empty/empty_action.py", line 71, in run_action self.emptier.do_empty(delete_pass.trash_dirs, args.environ, File "/usr/local/lib/python3.10/dist-packages/trashcli/empty/emptier.py", line 27, in do_empty for path in self.files_to_delete(trash_dirs, environ, parsed_days): File "/usr/local/lib/python3.10/dist-packages/trashcli/empty/emptier.py", line 50, in files_to_delete for orphan in self.trash_dir_reader.list_orphans( File "/usr/local/lib/python3.10/dist-packages/trashcli/lib/trash_dir_reader.py", line 18, in list_orphans for entry in self.dir_reader.entries_if_dir_exists(files_dir): File "/usr/local/lib/python3.10/dist-packages/trashcli/fs.py", line 97, in entries_if_dir_exists for entry in os.listdir(path): PermissionError: [Errno 13] Permission denied: '/.Trash-0/files'

trash-cli version 0.23.11.10

I am showing /.Trash folder access permission error when using trash-empty. It seems that it incorrectly searches for other user's .Trash folder, actually my user id is 1004. I would like to ask what is the reason for this? How does the program search the path to the recycle bin? How can I exclude it from searching directories under certain file systems? Thanks!

andreafrancia commented 3 months ago

Please open a new issue, use the issue template named "Bug report" and compile all the fields.