0

I'm writing a Qt app to run in Flatpak sandbox. I'm stuck with opening files, as it opens the file chooser dialog, I select the file and then the app crashes with File Not Found error.

I checked the /run/user/1000/doc/ directory, the correct folder gets created and it contains the selected file all well, just that the app doesn't see it. I'm using XDG portal to open file.

I'm not able to solve this problem.

Thanks in advance.

compiler
  • 486
  • 1
  • 4
  • 14
  • As I understand it the XDG portal gives you back an open file descriptor. If you are checking (directly or indirectly because of libraries) whether or not the *path* exists then that should fail if you run in sanboxed mode because of the private mount namespace (your app cannot see outside of it). – user268396 Jan 19 '19 at 10:54
  • Lets say if i select a file `/home/some_user/Downloads/some_file.pdf` The Portal creates a copy of the file in the dir `/run/user/1000/doc/1ba0a453/some_file.pdf` I get the this /run/user/... path in the app. But this file exists because portal has copied it but the app does not find it. – compiler Jan 20 '19 at 08:05
  • Quick question: what version of Qt are you using? I ask because with recent-ish versions of Qt there's been work on flatpak QPA plugin stuff like file chooser dialogs. – user268396 Jan 20 '19 at 11:23
  • Also: it turns out I was wrong previously. The file chooser portal gives you an URI. But what it actually does is mark the requested file in a database of permissions, which is used by the document portal to control actual access to the file. So the URI is more like a token. You are not supposed to open it directly, but give it to the document portal which can open it for you. – user268396 Jan 20 '19 at 11:26
  • There is some [documentation](https://flatpak.github.io/xdg-desktop-portal/portal-docs.html) But I haven't really seen good examples of how to use this. – user268396 Jan 20 '19 at 11:27

0 Answers0