tchx84 / Portfolio

A minimalist file manager for those who want to use Linux mobile devices.
GNU General Public License v3.0
94 stars 23 forks source link

Permission issue with the new trash folder feature #199

Closed dbeley closed 3 years ago

dbeley commented 3 years ago

Hi,

First of all, thanks a lot for this wonderful app, fully mobile-compatible linux apps are hard to come by!

With the latest Portfolio 0.9.11, it seems there is a permission issue with the new trash folder feature.

When I run the app from the app drawer, it fails silently. When I run it from the terminal, the stacktrace is the following:

Traceback (most recent call last):
  File "/usr/bin/dev.tchx84.Portfolio", line 40, in <module>
    from portfolio import main
  File "/usr/lib/python3.9/site-packages/portfolio/main.py", line 28, in <module>
    from .window import PortfolioWindow
  File "/usr/lib/python3.9/site-packages/portfolio/window.py", line 29, in <module>
    from .worker import PortfolioCutWorker
  File "/usr/lib/python3.9/site-packages/portfolio/worker.py", line 30, in <module>
    from .trash import default_trash
  File "/usr/lib/python3.9/site-packages/portfolio/trash.py", line 177, in <module>
    default_trash = PortfolioTrash()
  File "/usr/lib/python3.9/site-packages/portfolio/trash.py", line 41, in __init__
    self.setup()
  File "/usr/lib/python3.9/site-packages/portfolio/trash.py", line 55, in setup
    self._setup_trash_dir(trash_dir)
  File "/usr/lib/python3.9/site-packages/portfolio/trash.py", line 44, in _setup_trash_dir
    os.makedirs(os.path.join(trash_dir, "info"), exist_ok=True)
  File "/usr/lib/python3.9/os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib/python3.9/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission non accordée: '/.Trash-1000'

Portfolio is trying to create a Trash folder in my root directory, hence the permission issue.

The issue is resolved if I manually create the Trash folders in the root directory:

sudo mkdir -p /.Trash-1000/files
sudo mkdir -p /.Trash-1000/info

It might come from my configuration, I'm using archlinux ARM with the phosh desktop environment and this storage configuration:

# df -h
Sys. de fichiers      Taille Utilisé Dispo Uti% Monté sur
dev                     1,4G       0  1,4G   0% /dev
run                     1,5G    1,6M  1,5G   1% /run
/dev/mapper/cryptroot    29G    6,2G   21G  23% /
tmpfs                   1,5G    568K  1,5G   1% /dev/shm
tmpfs                   1,5G    8,0K  1,5G   1% /tmp
/dev/mmcblk0p1          115G     85G   24G  79% /home/alarm/SD
/dev/mmcblk2p1          243M    107M  137M  44% /boot
tmpfs                   300M     72K  300M   1% /run/user/1000

The workaround works for me but it's not really a good practice to have that kind of folder in the root directory, that's why I'm still reporting it.

henrythemouse commented 3 years ago

I don't have this version yet, running Mobian. One thing you might try (if you haven't already) is to remove that root Trash folder and manually create on in the users home dir (or /home/user/.local/share).

Portfolio might be looking there first and then defaulting to the root dir as a last attempt.

dbeley commented 3 years ago

Unfortunately it doesn't work, I've tried creating a folder at ~/.Trash-1000 and ~/.local/share/.Trash-1000 but it still try to create one at /.Trash-1000.

tchx84 commented 3 years ago

Unfortunately it doesn't work, I've tried creating a folder at ~/.Trash-1000 and ~/.local/share/.Trash-1000 but it still try to create one at /.Trash-1000.

hmm, I will check this tonight...

tchx84 commented 3 years ago

hey @dbeley , I can't reproduce this, but I think I understand what's happening....

Do you mind helping me test this PR https://github.com/tchx84/Portfolio/pull/200 ?