GtkFileChooser returns a directory
Maybe this could be split in 2 different bugs...? They are rather similar and maybe it's the same bug.
Steps to reproduce
- Create a directory
outer
with a subdirectoryinner
; - Open a software which can save a file and which will use GTK File Chooser for that. I will report here three cases: gedit (checks that the full path is valid before trying to save), LibreOfice (do not check, but adds an extension to the path), Firefox (do not check and uses directly the received path, most problematic case);
- In the Firefox case, configure so that it asks where to save the downloaded files: in "Preferences/General/Files and Applications/Downloads/Always ask you where to save files";
- Click the save button (in gedit or LibreOffice) or try to download something (in Firefox);
- In the GtkFileChooser dialog enter the
outer
directory.
From this point on I want to report two different and interesting ways for proceeding:
Bug A
- Click on the magnifying lens for searching (but don't type);
- Click on the field for editing the file name (but don't type);
- Click on the "Save" button;
Bug B
- Click on the
inner
directory; - Click on the magnifying lens for searching (but don't type);
- Click on the field for editing the file name (but don't type);
- Click on the "Save" button.
Current behavior
Bug A
- On gedit the dialog will stays open, no bug.
- On LibreOffice and on Firefox the dialog will close as if it succeeded but no file is saved.
Bug B
- On gedit: gedit realizes that the returned value is invalid and throws a message in the GUI
“/home/.../outer/inner” is a directory.
Please check that you typed the location correctly and try again.
- On LibreOffice Writer: a file
inner.odt
gets saved. - On Firefox: the file is saved with a temporary name inside
inner
(something likeinner/2uD3RGf1.pdf.part
) and the permissions of theinner
directory gets changed removing the executable bit (i.e. it takes the permissions of the downloaded file).
Expected outcome
Bug A
- On gedit behaves correctly;
- On LibreOffice and on Firefox I would expect that the file gets saved with the expected name inside the
outer
directory OR that the dialog stays open until when the search form is closed.
Bug B
- On gedit the error message is clear. This makes clear that GtkFileChooser returns the direction of the
inner
directory instead thanouter/Untitled Document 1
which would be expected. - On LibreOffice: as the file name form says
Untitled 1
, one would expect the file to be saved with the nameouter/Untitled 1.odt
instead thanouter/inner.odt
. - On Firefox: the permissions of the
inner
directory should be unchanged and the file should be saved with the original name inside theouter
directory (instead than inside theinner
one).
Version information
Confirmed both on an updated Arch Linux with GTK 3.24.24 and on Ubuntu 20.04.1 with GTK 3.24.20. On Ubuntu, the software versions were gedit 3.36.2, LibreOffice 6.4.6.2 and Firefox 84.0.2. On Arch, the software versions were gedit 3.38.1, LibreOffice 7.0.4.2 and Firefox 84.0.2.
Edited by ilario