mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-11-26 19:40:04 +01:00
- redact credentials from transport errors, verbose request logs, and download-start logs; add sid/api_key/sign to sensitive params - stop forwarding Yandex OAuth headers to API-supplied download hosts and give the last.fm mirror an opt-out and a notice - serialize deezer token state, beatport token snapshots, and qobuz mobile KEK access so concurrent workers cannot race login refreshes - suffix colliding track/video output names instead of overwriting - propagate deezer/qobuz pagination errors, keep paginating when counts are missing, and return a non-zero exit for partial album/playlist rips - clear failed_downloads rows on success and downloads rows on failure; open browse databases read-only; honor independent DB feature flags - drop the redundant deezer metadata call, paginate Yandex searches, bound and rate-limit yt-dlp, and deep-clone the SoundCloud cache - validate conversion codecs before ripping and isolate the qobuz convert smoke test from the real library - write the config atomically and fix deezer slug-vs-id URL parsing
68 lines
1.6 KiB
Go
68 lines
1.6 KiB
Go
package store
|
|
|
|
import "context"
|
|
|
|
type Database interface {
|
|
IsDownloaded(ctx context.Context, source, id string) (bool, error)
|
|
MarkDownloaded(ctx context.Context, source, id string) error
|
|
MarkFailed(ctx context.Context, source, mediaType, id string) error
|
|
Close() error
|
|
}
|
|
|
|
// FeatureFlags gates each database-backed feature independently. The config
|
|
// has separate downloads_enabled and failed_downloads_enabled switches, but a
|
|
// single SQLite file holds both tables; without this wrapper, enabling either
|
|
// switch silently enabled both.
|
|
type FeatureFlags struct {
|
|
DB Database
|
|
DownloadsEnabled bool
|
|
FailedEnabled bool
|
|
}
|
|
|
|
func (f *FeatureFlags) IsDownloaded(ctx context.Context, source, id string) (bool, error) {
|
|
if !f.DownloadsEnabled {
|
|
return false, nil
|
|
}
|
|
return f.DB.IsDownloaded(ctx, source, id)
|
|
}
|
|
|
|
func (f *FeatureFlags) MarkDownloaded(ctx context.Context, source, id string) error {
|
|
if !f.DownloadsEnabled {
|
|
return nil
|
|
}
|
|
return f.DB.MarkDownloaded(ctx, source, id)
|
|
}
|
|
|
|
func (f *FeatureFlags) MarkFailed(ctx context.Context, source, mediaType, id string) error {
|
|
if !f.FailedEnabled {
|
|
return nil
|
|
}
|
|
return f.DB.MarkFailed(ctx, source, mediaType, id)
|
|
}
|
|
|
|
func (f *FeatureFlags) Close() error {
|
|
return f.DB.Close()
|
|
}
|
|
|
|
type Dummy struct{}
|
|
|
|
func NewDummy() *Dummy {
|
|
return &Dummy{}
|
|
}
|
|
|
|
func (d *Dummy) IsDownloaded(context.Context, string, string) (bool, error) {
|
|
return false, nil
|
|
}
|
|
|
|
func (d *Dummy) MarkDownloaded(context.Context, string, string) error {
|
|
return nil
|
|
}
|
|
|
|
func (d *Dummy) MarkFailed(context.Context, string, string, string) error {
|
|
return nil
|
|
}
|
|
|
|
func (d *Dummy) Close() error {
|
|
return nil
|
|
}
|