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:
@@ -364,6 +364,50 @@ func (c *Config) SetScanConcurrency(mode string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetDownloadPreferences returns the configured auto-download
|
||||
// guardrails.
|
||||
func (c *Config) GetDownloadPreferences() download.AutoDownloadPrefs {
|
||||
if c.Downloads == nil {
|
||||
return download.AutoDownloadPrefs{}
|
||||
}
|
||||
|
||||
return c.Downloads.AutoDownloadPrefs()
|
||||
}
|
||||
|
||||
// SetDownloadPreferences saves new auto-download guardrails. This only
|
||||
// persists them; the download package cannot depend on config (config
|
||||
// already depends on download for UserConfig), so making the change
|
||||
// live without a restart is the caller's job — the frontend settings
|
||||
// save calls this and download.Service.SetPreferences in the same
|
||||
// action, and app.go's initDownloadRuntime applies the saved value to
|
||||
// the running Manager at startup.
|
||||
func (c *Config) SetDownloadPreferences(prefs download.AutoDownloadPrefs) error {
|
||||
if c.Downloads == nil {
|
||||
c.Downloads = &download.UserConfig{}
|
||||
c.Downloads.ApplyDefaults()
|
||||
}
|
||||
|
||||
formats := make([]string, 0, len(prefs.AllowedFormats))
|
||||
for _, f := range prefs.AllowedFormats {
|
||||
formats = append(formats, string(f))
|
||||
}
|
||||
|
||||
c.Downloads.MinFileSizeMB = prefs.MinSizeMB
|
||||
c.Downloads.MaxFileSizeMB = prefs.MaxSizeMB
|
||||
c.Downloads.PreferredFileSizeMB = prefs.PreferredSizeMB
|
||||
c.Downloads.AllowedFormats = formats
|
||||
|
||||
if err := c.Save(); err != nil {
|
||||
return fmt.Errorf(
|
||||
"could not save config: %w", err,
|
||||
)
|
||||
}
|
||||
|
||||
c.logger.Info("download auto-pick preferences updated")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetThemeAccentColor returns the configured accent colour.
|
||||
func (c *Config) GetThemeAccentColor() string {
|
||||
if c.Theme == nil {
|
||||
|
||||
Reference in New Issue
Block a user