owncloud / music

:notes: Music app for ownCloud
GNU Affero General Public License v3.0
553 stars 198 forks source link

Automatic re-scan does not work when renaming files or deleting folders #919

Open frake65 opened 2 years ago

frake65 commented 2 years ago

As far as I understood the meta information should be updated within the database when new files occur (scan is scheduled via UI) and also when a file / folder is deleted or renamed. This is not working for me that way and therefore I scheduled the command occ music:scan --rescan --clean-obsolete on a regular basis. That command nearly always leads to a deadlock #918 - so it's neither working for me. The new option rescan-modified is not active, yet and may be of help in future, but I'm not sure about that.

paulijar commented 2 years ago

How do you update or delete those files? If it doesn't happen via the Nextcloud web UI or PC/mobile client, then Nextcloud doesn't notice when it happens, and it can't notify the Music app either. In case the files are on some external storage, then Nextcloud probably does notice the changes when you later navigate to the folder in question from the web UI. But when this happens, it doesn't fire any of those modification events which are listened by the Music app. So then all you can do is to use occ music:scan.

Note that even the forthcoming occ music:scan --rescan-modified sees only those modifications which have been already noticed by Nextcloud. So you probably need to either navigate to the folder with the changed files or run occ files:scan before occ music:scan.

frake65 commented 2 years ago

Thanks for your instant feedback! - Update of files is mostly done via Mac desktop client. Actually I did some re-arrangements regarding meta data using Apple Music and Strawberry as my tools. The storage used on Nextcloud site is a local one. So over all everything looks quite straight forward to me. Files were moved around by Apple Music. On update of the meta data inside also no automatic rescan is scheduled - so e.g. nothing changes on UI if I change the name of an album.

frake65 commented 2 years ago

Just some more details from what I could see in this issue:

paulijar commented 2 years ago

Okay, thanks. So it sounds like the file modification hooks would never fire on your system. Which is weird as they do work fine for me both on new and old versions of Nextcloud.

If you enable the debug logging by settings loglevel => 0 in the file nextcloud/config/config.php, and then delete one of the music files belonging to your music library, then what can you find from the nextcloud.log file? There's probably plenty of logging there and most of it is uninteresting, but there could be also some clues within.

benklaasen commented 2 years ago

Hi - I see the same behaviour (modified files are not rescanned) when changing audio file metadata.

For example, I add several tracks in a folder to the Music folder in the locally-synched copy of my Nextcloud files. The Music app picks them up immediately and does its best to add them to the library based on the metadata it finds, but if I then modify the metadata using say, Easytag, and save (those changes being correctly synched back to my Nextcloud server), Nextcloud Music doesn't notice that the files have been modified.

Should Nextcloud Music save a hash of each file and check for changes on rescan?

Thank you for all your work on Nextcloud Music! With its Subsonic support, it's a phenomenally functional bit of software which has completely removed my need to use proprietary music services.

paulijar commented 2 years ago

Should Nextcloud Music save a hash of each file and check for changes on rescan?

No hash is saved by Music but Nextcloud should fire a "file modified" hook whenever it detects a file modification. And the Music app attaches to this hook and rescans the file whenever the hook is triggered. So in essence, the Music app is supposed to react automatically on the file metadata changes.

When the file modification is synced to Nextcloud, what can you see in nextcloud.log? You should see even more information in the log if you set the logging level to 'debug' for the duration of the test.