Files
minstrel/internal/db/migrations/0083_import.up.sql
T
bvandeusenandClaude Opus 5.5 ebbc49b902
release / govulncheck (push) Successful in 14s
release / web (push) Failing after 15s
release / go (push) Failing after 1m16s
release / integration (push) Failing after 4m49s
release / android (push) Successful in 4m59s
release / Build signed APK (releases and dev) (push) Successful in 5m14s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
feat: import with verification, and a Wanted view of its own (M502 #5522)
A finished download is checked against MusicBrainz before anything is
filed: the files are paired with an edition's tracks by position or path,
and AcoustID, tag ids, lengths and titles say whether it is the album.
What is the album is copied into the library as
Artist/Album (Year)/Artist - Album - NN - Title, tagged with Picard's
MusicBrainz ids, and scanned; the download keeps seeding. What is not is
refused: set aside, removed from the client, and the album searched for
again. A download the check cannot settle waits for a person, who imports
it anyway or refuses it. Tracks the library already holds are skipped.

The wanted list leaves Admin for a top-level Wanted view, admin-only and
web-only, with tabs for Wanted, Activity (downloads and their imports,
the ones needing a person first), Missing files, Held, Following (with the
release-type profiles, moved off Integrations) and Blocked. The search
settings gain "File new music into" when the library has several folders.

The search pass logs why each failed search failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 10:36:21 -04:00

38 lines
2.0 KiB
SQL

-- Import with verification (M502 #5522): a finished download is checked
-- against the album it was grabbed for before anything reaches the library.
--
-- grabs (columns) how far the download has got, and what the import
-- made of it: the verdict, its reason and evidence,
-- where the files went.
-- grabs.end_reason a grab also ends by being imported, refused, or
-- found to be an album already held.
-- release_blocks.reason import: the files were not the album.
-- acquisition_settings which library folder new music is filed into
-- ('' = the first scan path).
ALTER TABLE grabs
ADD COLUMN progress real NOT NULL DEFAULT 0,
ADD COLUMN import_state text NOT NULL DEFAULT ''
CONSTRAINT grabs_import_state_check CHECK (import_state IN
('', 'downloading', 'waiting', 'importing', 'imported', 'refused', 'review', 'held', 'failed')),
ADD COLUMN import_reason text NOT NULL DEFAULT '',
ADD COLUMN import_detail jsonb NOT NULL DEFAULT '{}',
-- A person said "import anyway" to a download the check held for them.
ADD COLUMN import_forced boolean NOT NULL DEFAULT false,
ADD COLUMN import_attempts integer NOT NULL DEFAULT 0,
ADD COLUMN import_updated_at timestamptz,
ADD COLUMN imported_at timestamptz,
ADD COLUMN imported_files integer NOT NULL DEFAULT 0,
ADD COLUMN destination text NOT NULL DEFAULT '';
ALTER TABLE grabs DROP CONSTRAINT grabs_end_reason_check;
ALTER TABLE grabs ADD CONSTRAINT grabs_end_reason_check
CHECK (end_reason IN ('', 'superseded', 'imported', 'refused', 'held'));
CREATE INDEX grabs_live_idx ON grabs (grabbed_at) WHERE ended_at IS NULL;
ALTER TABLE release_blocks DROP CONSTRAINT release_blocks_reason_check;
ALTER TABLE release_blocks ADD CONSTRAINT release_blocks_reason_check
CHECK (reason IN ('operator', 'files', 'import'));
ALTER TABLE acquisition_settings ADD COLUMN import_root text NOT NULL DEFAULT '';