bleakgrey / tootle

GTK-based Mastodon client for Linux
GNU General Public License v3.0
404 stars 61 forks source link

Opening images fails silently #302

Closed wjt closed 3 years ago

wjt commented 3 years ago

What should happen:

I believe that the intended behaviour is: clicking on an image should open it in my system image viewer.

What happened instead:

Nothing visible.

Looking with Bustle I can see that Tootle calls the following portal method:

org.freedesktop.portal.OpenURI.OpenURI('', 'file://25145593432a38bebdd4c16c95.png', @a{sv} {})

Notice the malformed URI which appears to be file:// concatenated to a relative filepath.

If I enter the running Tootle's sandbox I can see that the file (and some others I tried) have been saved to (what Tootle believes to be) my homedir:

bash-5.1$ pwd
/sysroot/home/wjt
bash-5.1$ ls -la
total 176
drwxr-xr-x 4 wjt wjt   160 Apr 22 13:43 .
drwxr-xr-x 3 wjt wjt    60 Apr 22 13:38 ..
-rw------- 1 wjt wjt   148 Apr 22 13:44 .bash_history
drwxr-xr-x 3 wjt wjt    60 Apr 22 13:38 .local
drwxr-xr-x 3 wjt wjt    60 Apr 22 13:38 .var
-rw------- 1 wjt wjt 74723 Apr 22 13:39 10895068861c5a3f8a29cde002.png
-rw------- 1 wjt wjt  5456 Apr 22 13:40 25145593432a38bebdd4c16c95.png
-rw------- 1 wjt wjt 88071 Apr 22 13:39 988507221e4f1676aae6cb9fb.jpg

How to reproduce:

  1. Find a toot with an image
  2. Click the image

Build context:

Logs:

** Message: 13:46:12.272: Desktop.vala:48: Downloading file: https://files.mastodon.social/cache/media_attachments/files/106/108/691/314/125/982/original/2a38bebdd4c16c95.png...
** Message: 13:46:12.310: Desktop.vala:78: OK: File written to: 25145593432a38bebdd4c16c95.png
** Message: 13:46:12.310: Desktop.vala:11: Opening URI: file://25145593432a38bebdd4c16c95.png
wjt commented 3 years ago

Glancing at the code:

jarbus commented 3 years ago

Having similar issue, but instead of failing silently, I get "Error: Operation not supported", despite having sxiv as my default image viewer

4903000 commented 3 years ago

You can work around this by granting Tootle access to your home directory.

The path where the file is downloaded becomes truncated to just the file name when the environment variable used isn't available in the sandbox, then the file:// prefix is added and the resulting string is passed to a program outside the sandbox.

As an aside, here's a funny thing you can do once you can open images: Click on an attached image twice, fast enough that your second click is registered before the file has been downloaded. You'll get an error saying that the file couldn't be opened because it exists.

f512 commented 3 years ago

You can work around this by granting Tootle access to your home directory.

In case it helps somebody, (and in case this is not the right way to do it..), I share here the command that helped me do it and did the trick for me :

sudo flatpak override com.github.bleakgrey.tootle --filesystem=home