Implemented database cleaning#293
Implemented database cleaning#293lGuillaume124 merged 1 commit intoSonerezh:developmentfrom gs11:issue129
Conversation
|
LGTM |
|
This doesn't remove unused cover art. |
|
Good point, I'll fix that. I guess playlist membership should be removed as well if the database design doesn't use cascade for deletes. |
If we want to do something very nice (maybe a v2), the deleted songs should go into a "deleted_songs" table. Then the playlist will show the song grayed with a text message "Song has been removed". If there are no more dependencies like that, then the song can be removed from the "deleted_songs" table. |
|
@ltguillaume Cover art & playlist membership removal now implemented |
|
@MightyCreak Yeah, that might be feasible in the future. I took the simpler road for this pull req. |
|
@gs11 I don't think this will work: as far as I remember, the names of the cover art files are MD5 checksums, so if a song's cover art results in the same file, with the same checksum, it will re-use the existing file. So the relation cover art - song is one to many. I had a glance at your code, and it seems you'll remove the cover art without checking if other songs are using these files as cover art. |
|
@gs11 That's really all right, I am already glad you did this feature since I was waiting for someone to do it for a very long time! ;) @ltguillaume About the MD5 checksums, I guess the MD5 is based on the song file? If it is, then I guess the idea would be to do That might increase the update time, but I, for one, don't really care if it takes 1 min or 5, as long as the database is clean afterwards. |
|
@MightyCreak @ltguillaume I'll add a lookup to make sure that the covers are only removed once all references are gone. The MD5 is btw based on the artist & album. Btw, what has happened to the project/developers? The pull request queue is growing. |
|
I think I did this exactly the same way in my piece of code, yeah, just SELECT COUNT. I think I remember that the import process via web UI vs the import process via the command line interface is completely separate, so you'll have to implement these changes twice, correct? This was my code ltguillaume@6d0ffa7 but it's based on an older development commit, so things might have changed, |
|
Finally got around to look at this again. Working SQL statement: CakePHP version: However, the query only hangs here. The idea is to only delete the cover if count is 1.
Any ideas? |
|
I think it's a little bit complicated, that's for sure :P I just did this after I removed the song. I think my code here ltguillaume@6d0ffa7 might be hacky, I don't know (and it's only for the command line interface), but it has been working fine for months. |
|
Fixed the above query issue, my condition was ambiguous since source_path exist in both joined table. However, somehow the query returns two rows where the first row contains id & cover and the second contains the count. Troubleshooting.. |
|
Ok, issues resolved and this now seems to work just fine! Merging to my development-new branch. |
Files no longer found on the file system are now removed as part of the database update process.
Thus, import has been renamed to update in some parts of the view.
This fixes issue #129