MissingCore / Music

A Nothing inspired local music player.
GNU Affero General Public License v3.0
216 stars 13 forks source link

feat: Support tracks without tags #35

Closed cyanChill closed 3 months ago

cyanChill commented 3 months ago

Why

For the future folder feature & preparation for supporting decoding metadata for any audio file that Android supports, it would make sense to support tracks that don't have any tags.

How

Implementing this change requires a couple of steps:

  1. Create a database migration as we're changing the type on a column. This ended up being a bit more difficult than expected; given that Drizzle ORM doesn't automatically generate the migration file for SQLite and documentation for creating migrations manually is a bit sparse (spent most of my time wondering why my migration wasn't working and it was mainly due to not using --> statement-breakpoint for separating SQL statements and using a transaction inside the migration file, when it wasn't needed).
  2. Update the indexing logic & UI to support these changes. I mainly had to find where we call .artistName and see if it's a place where it's potentially null and potentially provide a fallback value. For the indexing logic, we can remove the throw statements when we check to see if the artist name or track name is undefined. We've wrote code to fallback to the filename of the track (removing the audio extension) to ensure the track name is defined.
  3. Add the migration code to allow checking of tracks we deemed as invalid in the past due to not having any tags.
  4. Update the backup logic as tracks can potentially not have an artist.

During this process, we also did some other changes:

Test Plan

We've uninstalled the current version of the app and then created a development version of the app built from the v1.0.0-rc.9 build. This allows us to test the migration logic and see if everything works as expected. On my device, we have at least 1 tagless track, so that shouldn't be saved into the database normally.

We'll then install this version of the app with the changes and we should expect to see this tagless track in the "tracks" page. We've also look at any interactions involving this tagless track to see that our UI adjustments are working as expected.

Checklist