Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relinking library directory should automatically rescan library #12858

Open
Be-ing opened this issue Feb 21, 2024 · 18 comments
Open

relinking library directory should automatically rescan library #12858

Be-ing opened this issue Feb 21, 2024 · 18 comments

Comments

@Be-ing
Copy link
Contributor

Be-ing commented Feb 21, 2024

Bug Description

Relinking a library directory in the Library preferences requires manually rescanning the library for Mixxx to find the files. This should be done automatically when saving the changed preferences.

Version

2.4.0

OS

Fedora 39

@manuelbertelli
Copy link

How do I assign this issue to me?

@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 22, 2024

There's no need to assign the issue, you can just go ahead and open a pull request when you have a fix implemented. Please include Fixes https://github.com/mixxxdj/mixxx/issues/12858 in your commit message so this issue gets closed automatically when the PR is merged.

@manuelbertelli
Copy link

Relinking = relocate dir?

@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 23, 2024

Yes, using the Relink button in the Library preferences.

@ronso0
Copy link
Member

ronso0 commented Feb 23, 2024

Why is a rescan required?

IIUC, if the (inner) directory structure didn't change (dirs or tracks renamed / deleted) all tracks should be updated correctly.
or are you referring to the relink after migrating the Mixxx db to another OS / computer / ...? In that case encoders (availability / version) might have changed and rescan might be needed.

@ronso0
Copy link
Member

ronso0 commented Feb 23, 2024

Note: relinking was actually broken before #12462 (dirs were update but not the tracks).

@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 23, 2024

are you referring to the relink after migrating the Mixxx db to another OS / computer / ...?

I noticed this issue when testing migration into the Flatpak sandbox https://mixxx.org/news/2024-02-21-official-flatpak-now-available-on-flathub/

@ronso0
Copy link
Member

ronso0 commented Feb 23, 2024

I saw that, but does that mean we need a full rescan in order to get access to each track?

@ronso0
Copy link
Member

ronso0 commented Feb 26, 2024

Okay, I tried this myself:

  • installed org.mixxx.Mixxx
  • (~/.mixxx exists but is empty)
  • copied mixxx.cfg and mixxxdb.sqlite to ~/.var/app/org.mixxx.Mixxx/.mixxx
  • start Mixxx with flatpak run org.mixxx.Mixxx
  • asks me for a music directory (mixxxdb.sqlite and config are ignored?), I pick one
  • close Mixxx
  • now I suddenly have ~/.mixxx
  • okay, so I copy mixxx.cfg and mixxxdb.sqlite there
  • start Mixxx, old music dirs are shown in Pref -> Library
  • relink one that is marked missing: no permission, no advice how to grant it
  • close Mixxx, research how to grant file permissions, do so with
    sudo flatpak override org.mixxx.Mixxx --filesystem=~/someMusicDir
    (I also used Flatseal for another directory)
  • start Mixxx
  • all tracks in ~/someMusicDir are accessible

Conclusion:

The rescan is not required in general. Relink is sufficient.
I did this test on Ubuntu 20.04.05. If this works differently on other OS, okay, but I don't agree we should demand the rescan until we figured when/why it is necessary.

@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 26, 2024

flatpak override org.mixxx.Mixxx --filesystem=~/someMusicDir

That will change the result. That shouldn't be required.

@ronso0
Copy link
Member

ronso0 commented Feb 26, 2024

The only useful dir permissions Mixxx has after installation are for /media and xdg-music. My main music directory is on another drive mounted in /mnt, and one in /home. In the Relink file picker there is no way to see other directories, let alone grant access. Neither https://flathub.org/apps/org.mixxx.Mixxx nor https://github.com/flathub/org.mixxx.Mixxx give any hints how to deal with this.

The Flatpak sandbox docs advice to use flatpak override [app-id] --filesystem=~/file/path.
As I wrote above, I also used Flatseal to grant access to another directory: no relink required, no issues.
(FWIW Flatseal did not list the dir I added previously with flatpak override org.mixxx.Mixxx --filesystem=)
When I test with a music dir in /media: no relink required, no issues.

This is with
flatpak-1.6.5-0ubuntu.4
xdg-desktop-portal-1.6.1-1ubuntu2

@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 26, 2024

In the Relink file picker there is no way to see other directories

Really? The file picker dialog goes through the XDG File Chooser portal, so it should let you choose any directory that your user has permission to, including outside the Flatpak sandbox.

@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 26, 2024

The only useful dir permissions Mixxx has after installation are for /media and xdg-music.

Right, relinking is only needed if the user already had directories outside of these paths in their Mixxx database.

@ronso0
Copy link
Member

ronso0 commented Feb 26, 2024

In the Relink file picker there is no way to see other directories

Really? The file picker dialog goes through the XDG File Chooser portal, so it should let you choose any directory that your user has permission to, including outside the Flatpak sandbox.

What shall I say, xdg-desktop-portal is 1.6.1-1ubuntu2 which is quite old I guess.
Anyhow, please simulate the migration yourself again and verify a rescan is indeed still required.

@Toneplay
Copy link

Would rescanning after a Relink ever be a terrible thing? Wouldn't it be fast if it isn't necessary (that is, if the records for the relinked folder are already in the library)?

Maybe after Relinking, rather than forcing a rescan, we should make rescanning optional and prompted, just as we do when the user Adds a new directory.

It seems wrong not to warn the user that the directory they just relinked might not be available until rescan.

@ronso0
Copy link
Member

ronso0 commented Jan 10, 2025

It seems wrong not to warn the user that the directory they just relinked might not be available until rescan.

The dir is available immediately, relinking just replaces the file paths in the database which is blazing fast.
If that doesn't work please file a bug report.
(Note: this was not the case when relinking was broken, so I suggest you try again with Mixxx 2.5, or at least 2.4.1 where I fixed it)

Would rescanning after a Relink ever be a terrible thing?

Define 'terrible' ; )
Thing is, currently we can only rescan ALL directories. Directories can be

  • huge
  • on various partitions, incl. slow HDD

Rescan blocks the GUI (to avoid database inconsistencies caused by concurrent access (scanner vs. user modifications like metadata edit, play count etc.) and it can take long.
So, considering it's not necessary for relinking I vote for not doing it automatically.

Refactoring the scanner to allow scanning specific directories is an option though, as well as offering a specific rescan after relinking.
Related:
#13989
#14142
#8532

@Toneplay
Copy link

Toneplay commented Jan 11, 2025

The dir is available immediately,

It is not, if rescanning is enabled at startup and you just started Mixxx. The rescan removes the entries, so it's just like a "Remove" in terms of library contents.

Also, the user might (erroneously, maybe) Relink to a ("bogus") folder that doesn't match the entries in the library. In this case, the user might want to be informed of the error, rather than being forced to rescan and "cement" the error in the contents of the library.

I don't like the idea of forced rescan, especially if it will rescan ALL the directories rather than only the ones Relinked or Added.

I don't see a manual rescan button in 2.5.0. Maybe we should have a button for that, and some indication that Relink could require a rescan after you do it. I think the user should initiate rescans, since they are potentially so expensive.

@ronso0
Copy link
Member

ronso0 commented Jan 12, 2025

It is not, if rescanning is enabled at startup and you just started Mixxx. The rescan removes the entries, so it's just like a "Remove" in terms of library contents.

... and auto-rescan bites us again 😞
In that case Move tracks -> start Mixxx -> auto-rescan another rescan is required after relinking.
For the reasons mentioned above rescaning only affected directoies would be preferrable.

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

No branches or pull requests

5 participants