flathub / org.mixxx.Mixxx

https://flathub.org/apps/details/org.mixxx.Mixxx
7 stars 6 forks source link

Can't import playlists referencing files outside the sandbox #45

Open sgala opened 1 year ago

sgala commented 1 year ago

When I try to use org.mixxx.Mixxx, first step is to point it to my Library. I point to /run/media//9016-4EF8/MP3 (a SD card that contains tracks and playlists for tango DJ, and it indexes it correctly. Then I go to Playlists>Import Playlist, and point it to /run/media//9016-4EF8/MP3/2009-12-29-Artebar.m3u, and the import comes empty. If I start the flatpak in the command line I can see lots of messages like "QFileInfo(/run/user/1000/doc/338c668b/milongas/2009-12-29/La Cumparsita (1951).mp3) not found" because, in effect, the file in the trask shows at properties that it is at /run/user/1000/doc/2c9bb936/MP3/milongas/2009-12-29/La Cumparsita (1951).mp3. I have tried several workarounds, including using "document-export", which returns the "2c9bb936" path but it is still not used for Import. While "flatpak enter org.mixxx.Mixxx cat /run/user/1000/doc/2c9bb936/MP3/2009-12-29-Artebar.m3u" works, I can't specify this path for the import dialog box or similar ones for the import Dialog box.

I don't know anything about flatpak, but my guess is that playlists inside the Track Library documents should be accessed through the flatpack document they are in, and not create a new one. This would fix the issue.

Be-ing commented 1 year ago

This is likely due to Flatpak sandboxing. The Flatpak is only given permission to access your XDG music directory (~/Music by default). I think that the Qt file picker dialog automatically uses the XDG file picker portal under the hood which can give permission to other files. I'm not sure how to explain the discrepancy between /run/media//9016-4EF8/MP3 and /run/user/1000/doc/2c9bb936/MP3 though. It seems the portal is only giving permission to access the former?

FakeShemp commented 1 year ago

I think it's to do with M3U playlists being relatively pathed as well. It expects the music files to be in the same folder as the M3U itself, but to the sandbox, that might not be the case.

You can probably add --filesystem=/run/media/ when starting and then importing the playlist should work.

sgala commented 1 year ago

Of course playlists need to be relative, otherwise I would loose all portability between different devices that I have managed for 15 years with MP3 players, cellular phones and different computers with different library "roots".

I tried --filesystem=/run/media and it doesn't work, but looking into the manual I tried other options. The only one that worked is --filsystem=home. All the remaining variantes, filesystem=/run/media, or =xdg-documents or =xdg-run/doc and the library that I specify as /run/media/sgala/9016-4EF8/MP3 comes as /run/user/1000/doc/7e1e1509/MP3 and each playlist gets "imported" with a different path. So I have a workaround, thanks!

sgala commented 1 year ago

It is actually funnier than I expected, something is definitely broken: when I use --filesystem=host playlist import still doesn't work, as playlists get the funky name. BUT, and it is an important but, when I use --filesystem=host mixxx shares its data with the rpm package, which means I can execute the (graphically more buggy) rpm to import playlists and they get imported in the proper path, and then run the flatpak (which is just pathname buggy for what I have seen). Not sure if I make sense. In any case, thanks for your work :)

Be-ing commented 4 months ago

I reproduced this issue locally and it's tricky. I don't think there's any nice way to deal with this using portals, at least not yet. I started a discussion on the xdg-desktop-portal repository to ask for advice.

If the file paths referenced by the playlist are within the paths the Flatpak has static permissions to access, it works whether the paths in the playlist are relative or absolute. This includes the XDG Music directory (~/Music) and with #54, /media and /run/media, which should resolve your particular case with the SD card @sgala. So for now, I'd suggest any user that stumbles on this issue to use Flatseal to modify the filesystem permissions to add the directory where the music files listed by the playlist are.