Found reviewing the branch: a request cancelled between deleting the file and updating the index left a track whose file does not exist. The index step no longer depends on the request's context. Test first: it cancels the request at exactly that moment.
README: the Duplicates feature, the new setting and its environment variable, the endpoints, and the two places that promised the music folders are never written. The example config and the compose file say how to turn it on and that the folder must then be writable.
Admin only. GET /library/duplicates lists the groups with what is needed to choose and never a path; POST|GET|DELETE /library/duplicates/check is the job that fingerprints the files; POST /library/duplicates/clean deletes the chosen copies of one song, each refusal with its own status and code (deletion_disabled, scan_running, invalid_input, track_not_found, duplicate_changed, library_read_only). In the spec with the contract test, and wired in main, where an info line says when library.allow_delete is on.
Groups come from the index. The check job reads the files of the groups and keeps their SHA-256, skipping a file that changed since the scan. Clean refuses unless deleting is on and no scan runs, works out again that the tracks are copies of one song, checks every file is still what the scan saw (so the last copy is never removed, and a link or a path that leaves the library is refused) before removing any, removes each file through an os.Root, then takes its track out of the index and moves its listens. Tested with real files, including the refusals; three of the safety rules were broken on purpose to see the tests fail.
Candidates are the playable files whose title another file shares. A fingerprint is kept only for the file that was read (same size and date), and a scan that finds the file changed forgets it. Removing a copy moves its listens to the track that stays, because they would be deleted with the track, then removes the track with its file, credits and genres. Tested on SQLite and PostgreSQL.
Many titles end with a note taken from the tags: (disc 2), (bonus disc),
(Deluxe Edition), sometimes cut off by a tag that is too short. A release group is
named after the album, not after a disc, so those albums found nothing.
The lookup now asks for the title as it is first and, only when MusicBrainz has no
sure result, once more without the notes at its end (baseTitle). A group in brackets
with none of the words of a note stays part of the title, and a title that would be
left empty is kept. The rule for accepting a result does not change.
On 25 albums of a real library with such notes, 19 found a cover (none before).
Closes#87
The same song is the same set of main artists, the same title and durations within 3 seconds, every pair within it; a file with no duration or no artist never matches. A group says whether its files were all read and are byte for byte the same. The copy to keep is the lossless one, then the higher bitrate, then the bigger file, then the oldest, whatever the order of the input.
The one setting that lets Sonda delete files from the music folders. Off until the operator turns it on, in the file or with SONDA_ALLOW_DELETE; a value that is not true or false is an error, not ignored.
The covers asked the Cover Art Archive only for albums whose files carried a
release group id. In a library tagged without MusicBrainz, 3,321 of 3,433 albums
have none, so almost no cover could come from the archive.
An album with no id is now looked up in MusicBrainz by the name of its artist and
its title (musicbrainz.Client.FindReleaseGroup), when the musicbrainz provider is
on too. A result is taken only if MusicBrainz scores it 95 or more and its title
and one name of its artist credit equal the ones asked for after folding case,
accents and punctuation; the first such result wins and anything doubtful is no
cover. The id is used for that request and is not stored on the album.
Artists are still never looked up by name. The MusicBrainz and Cover Art Archive
provider texts, the README and the API spec say what is sent.
On 47 albums sampled from a real library, 23 got a cover (all checked as the right
ones by eye or by exact title and artist); a title like 'Live (disc 2)' finds nothing.
Closes#83
make build builds the app and then sondad with -tags webui. The Dockerfile builds the app in a Node stage and embeds it in the Go build, so the image serves it with no Node on the host. README: how to build, what the image holds, the policy of the page, and how to work on the interface with the dev server.
internal/webui carries web/'s build (written to internal/webui/dist by Vite, git-ignored) when sondad is built with -tags webui. Without the tag the app is absent and a plain go build and go test still work with no Node. main wires it into the router.
A GET or HEAD outside /api is a file of the app, or its page for a link inside it (/admin/users). A file that is missing (under assets/ or with an extension) answers 404, never the page, so a missing script is not run as HTML; hidden files and folders are never served; everything else, and any unknown /api address, keeps the JSON 404. The page gets a Content-Security-Policy that allows only its own server (no address, no wildcard, no inline script), nosniff, DENY and no referrer. Hashed assets are cached for good and the page is asked again. With no app in the binary, / says how to build it. The app is an optional dependency, so existing wiring is unchanged.
The test read the address right after the Artists section appeared, but the address is updated by an effect a moment later. On a busy machine it failed in every full run and passed alone. Closes#80.
Three cards at /admin/jobs, for admins only; anyone else gets the notice and the server is not asked. The page reads which providers are on to block a job whose provider is off. README says the admin area now covers everything the API offers an admin.
Starting asks first and says the job goes through the whole library and what it sends; reading everything again is a separate choice. A job whose providers are off cannot be started and the card says which. The status follows the job while it runs.
One set of hooks for the three jobs: read the status (again and again while it runs, by itself stopping), start (optionally reading everything again) and stop.
The level is kept while muted so unmuting brings it back, moving it unmutes, pressing mute on silence raises it instead of doing nothing, and a browser that refuses storage just forgets it.
One card for each provider at /admin/providers, for admins only; anyone else gets the notice and the server is not asked. README says what the admin area covers.
Nothing is asked of Lidarr until the admin loads its choices on purpose, which needs its address and a key. A folder Lidarr cannot use is shown and cannot be picked; saving sends all the options at once.
Turning a provider on asks first and repeats what it will be sent; one that needs a key or an address cannot be turned on without it and the card says why. The key is never shown or filled in, and is gone from the page once saved; removing it says it also turns the provider off. The confirm dialog is now shared with the users section.
Found in a real browser: after the complaint, typing a valid password left it on screen until the next submit. Same in the reset dialog and the add form.
Opens at /admin/users next to Libraries, for admins only; anyone else gets the notice and the server is not asked. README says what the admin area covers.
Give the admin role at once, take it away or delete an account after a question, reset a password in a dialog that forgets it (and ends that person's sessions), and add an account by email. Your own row has no buttons, and the last admin cannot be changed: the page says so.
The tests of Discover, the Lidarr button and the admin libraries built a signed-in user with a username, which no longer exists since accounts are identified by email. They passed, but the type check failed on 18 fixtures and so did npm run build. Closes#71.
The Admin link is shown only to an admin and /admin opens the libraries. Someone else who opens the address gets a notice and the server is not asked anything. README describes what the admin area covers so far.
The admin frame shows its sections only to an admin and asks nothing of the server for anyone else. Libraries can be added, edited (only what changed is sent) and removed after a confirmation that says the music on disk is never touched; a scan can be started for one library or all, optionally reading every file again, and the panel follows it and shows the summary, with the files in unsupported formats standing out.
Registration, login and the admin's create-user call take `email` instead of
`username`, and the user object returns `email`. The address is checked for its
shape (a plain address, no display name, at most 254 bytes), trimmed, lowercased
and unique. Sonda sends no mail and does not verify it.
- Migration 0018 renames the users column (and the PostgreSQL index); values are
kept, so an account made before keeps its plain name and still logs in with it
(login does not check the shape).
- Error code username_taken becomes email_taken; the JWT claim is now `email`,
so access tokens issued before the upgrade are refused once and clients refresh.
- OpenAPI spec, README, the web login form (type email), strings (en, it) and
the generated API types follow.
Closes#65
List, add, rename or move and remove libraries, start a scan of one or all (reading every file again on request), and follow the scan by reading its status while it runs.
The artist page reads what Lidarr has first, so it also works for an artist the library has nothing of. A card does not ask Lidarr anything until an admin sends the artist.
Only an admin gets it. It reads what Lidarr has before showing itself (or, on a list card, not at all), asks before sending, sends one artist once, and explains every outcome in words, including a timeout that rereads the state. The API types are regenerated from the spec, which gained the Lidarr endpoints and providers since they were last built.
Reading is a status, never an error. Sending is one POST for one artist; when it worked, or Lidarr did not answer in time, what Lidarr has is read again.