Skip to content

Support MIME subclasses in dialog scanning#1669

Open
norepro wants to merge 3 commits intopop-os:masterfrom
norepro:handle-derived-mime-types
Open

Support MIME subclasses in dialog scanning#1669
norepro wants to merge 3 commits intopop-os:masterfrom
norepro:handle-derived-mime-types

Conversation

@norepro
Copy link

@norepro norepro commented Mar 5, 2026

Fix a bug where files with MIME types that are sub-classes of the filtered MIME types do not appear in the file dialog.

The file dialog only does strict equality checks when deciding which file MIME types match the filter list types. Augment the logic to also check if files are a subclass of the filter types.

Common examples fixed by this are ISO files. Modern Linux systems identify them as application/vnd.efi.iso which would not appear if the filter only had, say, application/x-cd-image. Now they do.

Partially fixes #1596

  • I have disclosed use of any AI generated code in my commit messages.
    • If you are using an LLM, and do not fully understand the changes it is making to the code base, do not create a PR.
    • In our experience, AI generated code often results in overly complex code that lacks enough context for a proper fix or feature inclusion. This results in considerably longer code reviews. Due to this, AI authored or partially authored PRs may be closed without comment.
  • I understand these changes in full and will be able to respond to review comments.
  • My change is accurately described in the commit message.
  • My contribution is tested and working as described.
  • I have read the Developer Certificate of Origin and certify my contribution under its conditions.

@garrettjwilke
Copy link

testing the base example: boxes VM importing an ISO file

this does not display ISO files in Boxes.

i am unsure how to test beyond this, but the Boxes example does not work with this fix.

@norepro
Copy link
Author

norepro commented Mar 6, 2026

testing the base example: boxes VM importing an ISO file

this does not display ISO files in Boxes.

i am unsure how to test beyond this, but the Boxes example does not work with this fix.

You need to update https://github.com/pop-os/xdg-desktop-portal-cosmic to build with this updated cosmic-files before you will see GNOME Boxes behavior change. Updating cosmic-files alone is not enough because the COSMIC xdg portal does not spawn a process, it links it as a crate.

It is currently locked to commit e779fc from Nov 20, 2025:

https://github.com/pop-os/xdg-desktop-portal-cosmic/blob/master/Cargo.lock

[[package]]
name = "cosmic-files"
version = "0.1.0"
source = "git+https://github.com/pop-os/cosmic-files#e779fc3dac1dd1de2b5c8aa54c6bd5f872169635"

I tested it locally with a private build of xdg-desktop-portal-cosmic and configuring D-Bus to use it.

Does the team have a method of testing the dialog functionality that does not require a new build of xdg-desktop-portal-cosmic?

@norepro
Copy link
Author

norepro commented Mar 6, 2026

To test it locally with GNOME Boxes:

  1. Clone https://github.com/norepro/xdg-desktop-portal-cosmic . This is my fork for testing.
  2. git checkout gnome-boxes-fix. This branch is configured to use cosmic-files from this PR.
  3. cargo build --release
  4. Make a backup of /usr/share/dbus-1/services/org.freedesktop.impl.portal.desktop.cosmic.service
  5. sudo vi /usr/share/dbus-1/services/org.freedesktop.impl.portal.desktop.cosmic.service (or whatever editor you prefer)
  6. Replace /usr/libexec/xdg-desktop-portal-cosmic with [CLONE_LOCATION_FROM_STEP_1]/target/release/xdg-desktop-portal-cosmic . Save and exit.
  7. killall xdg-desktop-portal-cosmic
  8. GNOME Boxes should find your ISO files now. Note that "[Invalid UTF-8]" will still be there; that's a separate fix on GNOME Boxes side but is cosmetic.
  9. Restore the backup from step 4.

@jacobgkau
Copy link
Member

@norepro Thanks for providing the detailed testing steps! We can definitely build xdg-desktop-portal-cosmic locally to test this. For future changes like this, you'd also be welcome to open a draft PR against xdg-desktop-portal-cosmic with the Cargo.toml pointing to your cosmic-files branch (which would let us have our build server build it for testing), but it's of course not technically required.

It does look like this PR has a small conflict. Could you fix that, and we can take another look? (I'm not sure if #1650, which caused the conflict, obsoletes or changes what you're doing here in any way.)

@norepro
Copy link
Author

norepro commented Mar 9, 2026

@norepro Thanks for providing the detailed testing steps! We can definitely build xdg-desktop-portal-cosmic locally to test this. For future changes like this, you'd also be welcome to open a draft PR against xdg-desktop-portal-cosmic with the Cargo.toml pointing to your cosmic-files branch (which would let us have our build server build it for testing), but it's of course not technically required.

It does look like this PR has a small conflict. Could you fix that, and we can take another look? (I'm not sure if #1650, which caused the conflict, obsoletes or changes what you're doing here in any way.)

Conflicts are resolved! The changes are complementary: the incoming change adds matching for base/* syntax while mine adds support for sub-classes, e.g. showing application/vnd.efi.iso files when application/x-cd-image is in the allow list.

To my knowledge, there is no common base for image/*, so both changes are required.

Thanks for the tip on the draft PR! It's a good idea and I'll see if I can get that published in the next day or two.

@norepro
Copy link
Author

norepro commented Mar 10, 2026

Created a draft PR: pop-os/xdg-desktop-portal-cosmic#281 that pulls in this branch for testing.

Regarding my commit bca195c above that removed '.git' from libcosmic in Cargo.toml: it is to avoid some ugly patching syntax in crates that consume cosmic-files, like xdg-desktop-portal-cosmic. cargo sees URLs that end with '.git' as different than those that do not and creates a lot of hacks like adding '//' to URLs for patching.

COSMIC projects generally seem to prefer no '.git' suffix, so I'm setting that here as well to make them align. Bigger picture it would be nice if the various projects agreed on syntax, especially since git crates are so common 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cosmic file picker can't handle .iso files

4 participants