Bug 2183356

Summary: Flatpak build: when you use Evince's Open menu to open a file, Save as... does not save to the same directory you opened it from
Product: [Fedora] Fedora Reporter: Adam Williamson <awilliam>
Component: evinceAssignee: Marek Kašík <mkasik>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 39CC: feborges, gnome-sig, mclasen, mkasik, rstrode, sandmann
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Adam Williamson 2023-03-30 22:54:37 UTC
Recently - I think since the flatpaks were rebuilt on the F38 runtime - we're seeing a failure of the openQA Evince test on Silverblue (but not Workstation, where we use RPM-packaged Evince of course):

https://openqa.fedoraproject.org/tests/1861635#step/save_as/11

what's going on, best I can tell, is this.

What the test is trying to do is check that "Save As" behaves as intended. The test runs Evince from the overview (so it opens with no document loaded and an "Open..." button visible). It clicks the Open... button, navigates to the user's Documents folder, and opens a PDF that's there (we set that up earlier in the test). Then, it opens the burger menu, clicks "Save As...", types a new file name, and hits the Save button. It expects this to result in the newly-named file being saved in the same directory as the original file (Documents). On the RPM-packaged Evince, and previously with the Flatpak evince, this is what happened. Now, however, with the Flatpak evince, "Save As..." actually saves the file to a different folder entirely: it winds up in something like `/run/user/1000/doc/d3d864ff` (I'm guessing the final element is a random string).

Of course, we can tweak the test to switch to the Documents folder before saving. But it does seem like a wrong behaviour. I'm not sure if it can be fixed?

I've reproduced this manually, too. Notably, it does *not* happen if, instead of using Evince's own "Open..." button to open the file, I open it by going to the Documents folder in Nautilus and double-clicking the PDF file. On *that* path, when I hit "Save As...", the correct Documents folder is pre-selected as the save target.

Comment 1 Felipe Borges 2023-03-31 09:58:06 UTC
The "Open" button launches a FileChooser Portal[0], which doesn't expose the filesystem to the app. So the file path Evince gets comes from the portal (run/user/100/doc/...).

The "Save as" dialog uses g_file_get_parent()[1] to set the current target folder for saving, hence what you are experiencing.

To solve this issue the FileChooser portal would have to expose the current_dir to the sandbox, and that is tricky for various reasons discussed in https://github.com/flatpak/xdg-desktop-portal/pull/874

[0] https://gitlab.gnome.org/GNOME/evince/-/blob/main/shell/ev-window.c#L2887
[1] https://gitlab.gnome.org/GNOME/evince/-/blob/main/shell/ev-window.c#L3195

Comment 2 Fedora Release Engineering 2023-08-16 08:15:03 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 39 development cycle.
Changing version to 39.