refactor(download): rename Want/Request to Request/Download, unify downloads flow, add auto-download guardrails
The durable "I asked for this" record was called Want, and the one-shot search-and-grab attempt was called Request — names that didn't match what either actually did. Want is now Request, and the old Request/Item is now Download/DownloadItem, with a table-rename migration (download_wants -> download_requests, old download_requests -> download_downloads) safe against both fresh installs and existing data. Every anchored manual download now upserts/reuses a durable Request before running, so a "download now" that finds nothing is picked up by the background reconciler automatically instead of just failing with no trace — the gap that caused this session's repeated "no candidates found" failures on the same album. Also adds auto-download guardrails (file-size min/max with a preferred target, allowed file types) that gate what the pipeline may grab unattended, live-editable from a new settings section. The frontend's wanted-view becomes downloads-view, with a new Downloads tab showing attempt/transfer history that previously had no UI at all. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y2Agd9af5hE7qzti2ackiS
This commit is contained in:
+15
-13
@@ -142,10 +142,17 @@ var tables = []Table{
|
||||
"only; the sized variants beside it are derived filenames and " +
|
||||
"must be expanded when deleting (see library.coverArtFileSet).",
|
||||
},
|
||||
{
|
||||
Name: "download_downloads", Kind: Authored, Lifetime: Cascade,
|
||||
Note: "One row per 'go find me this', i.e. one search-and-grab " +
|
||||
"attempt. Cascades from libraries, and cascades onward to " +
|
||||
"download_items. Terminal rows are history the user clears " +
|
||||
"explicitly.",
|
||||
},
|
||||
{
|
||||
Name: "download_items", Kind: Authored, Lifetime: Cascade,
|
||||
Note: "One grab attempt per row, with the ranked candidate stored " +
|
||||
"as JSON. Cascades from download_requests. The candidate blob " +
|
||||
"as JSON. Cascades from download_downloads. The candidate blob " +
|
||||
"is kept rather than re-derived because a provider's result " +
|
||||
"set is ephemeral — the peer that had the files may be gone, " +
|
||||
"and the row still has to explain why it was chosen.",
|
||||
@@ -159,18 +166,13 @@ var tables = []Table{
|
||||
},
|
||||
{
|
||||
Name: "download_requests", Kind: Authored, Lifetime: Cascade,
|
||||
Note: "One row per 'go find me this'. Cascades from libraries, " +
|
||||
"and cascades onward to download_items. Terminal rows are " +
|
||||
"history the user clears explicitly.",
|
||||
},
|
||||
{
|
||||
Name: "download_wants", Kind: Authored, Lifetime: Cascade,
|
||||
Note: "The wanted list: one MBID per row, plus retry bookkeeping. " +
|
||||
"Cascades from libraries, and from a parent artist want to " +
|
||||
"the album wants it derived. Unlike download_requests these " +
|
||||
"are not history — a want outlives every attempt made on it " +
|
||||
"and is only removed by the user or by the library coming " +
|
||||
"to own what it names.",
|
||||
Note: "The durable request list: one MBID per row, plus retry " +
|
||||
"bookkeeping. Cascades from libraries, and from a parent " +
|
||||
"artist request to the album requests it derived. Unlike " +
|
||||
"download_downloads these are not history — a request " +
|
||||
"outlives every download attempt made on it and is only " +
|
||||
"removed by the user or by the library coming to own what it " +
|
||||
"names.",
|
||||
},
|
||||
{
|
||||
Name: "explore_champion_fts", Kind: Cache, Lifetime: Retained, FTS: true,
|
||||
|
||||
@@ -223,22 +223,23 @@ func TestAuthoredCascadesAreDeliberate(t *testing.T) {
|
||||
|
||||
// Download history is scoped to the library it imported into.
|
||||
// When that library is removed the files it acquired go with
|
||||
// it, so a request describing "fetch this into library 3" has
|
||||
// it, so a download describing "fetch this into library 3" has
|
||||
// nothing left to mean. Keeping the rows would leave history
|
||||
// pointing at a library the user deleted.
|
||||
"download_requests": true,
|
||||
"download_downloads": true,
|
||||
|
||||
// Items belong to their request and have no independent
|
||||
// Items belong to their download and have no independent
|
||||
// meaning; they cascade with it.
|
||||
"download_items": true,
|
||||
|
||||
// A want says "put this in library 3". Delete that library and
|
||||
// there is no longer anywhere for it to go, so the want has
|
||||
// nothing left to mean — the same reasoning as its requests.
|
||||
// The second cascade, artist want to derived album wants, is
|
||||
// the point of the subscription: unsubscribing from an artist
|
||||
// must stop the albums it queued on the user's behalf.
|
||||
"download_wants": true,
|
||||
// A request says "put this in library 3". Delete that library
|
||||
// and there is no longer anywhere for it to go, so the request
|
||||
// has nothing left to mean — the same reasoning as its
|
||||
// downloads. The second cascade, artist request to derived
|
||||
// album requests, is the point of the subscription:
|
||||
// unsubscribing from an artist must stop the albums it queued
|
||||
// on the user's behalf.
|
||||
"download_requests": true,
|
||||
}
|
||||
|
||||
for _, entry := range datamap.ByKind(datamap.Authored) {
|
||||
|
||||
Reference in New Issue
Block a user