mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-31 07:30:32 +00:00
refactor(scanner): simplify GC method by removing library ID parameter
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
01f68f4a75
commit
33704edc1c
@ -373,10 +373,10 @@ type extendedDataStore struct {
|
||||
gcError error
|
||||
}
|
||||
|
||||
func (ds *extendedDataStore) GC(ctx context.Context, libraryIDs ...int) error {
|
||||
func (ds *extendedDataStore) GC(ctx context.Context) error {
|
||||
ds.gcCalled = true
|
||||
if ds.gcError != nil {
|
||||
return ds.gcError
|
||||
}
|
||||
return ds.MockDataStore.GC(ctx, libraryIDs...)
|
||||
return ds.MockDataStore.GC(ctx)
|
||||
}
|
||||
|
||||
@ -43,5 +43,5 @@ type DataStore interface {
|
||||
|
||||
WithTx(block func(tx DataStore) error, scope ...string) error
|
||||
WithTxImmediate(block func(tx DataStore) error, scope ...string) error
|
||||
GC(ctx context.Context, libraryIDs ...int) error
|
||||
GC(ctx context.Context) error
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ func (s *SQLStore) WithTxImmediate(block func(tx model.DataStore) error, scope .
|
||||
}, scope...)
|
||||
}
|
||||
|
||||
func (s *SQLStore) GC(ctx context.Context, libraryIDs ...int) error {
|
||||
func (s *SQLStore) GC(ctx context.Context) error {
|
||||
trace := func(ctx context.Context, msg string, f func() error) func() error {
|
||||
return func() error {
|
||||
start := time.Now()
|
||||
@ -167,12 +167,6 @@ func (s *SQLStore) GC(ctx context.Context, libraryIDs ...int) error {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Implement library-specific filtering for GC operations
|
||||
// For now, GC runs globally even in selective scans
|
||||
if len(libraryIDs) > 0 {
|
||||
log.Debug(ctx, "GC: Running with library filter (not implemented)", "libraries", libraryIDs)
|
||||
}
|
||||
|
||||
err := run.Sequentially(
|
||||
trace(ctx, "purge empty albums", func() error { return s.Album(ctx).(*albumRepository).purgeEmpty() }),
|
||||
trace(ctx, "purge empty artists", func() error { return s.Artist(ctx).(*artistRepository).purgeEmpty() }),
|
||||
|
||||
@ -187,7 +187,7 @@ func (s *scannerImpl) runGC(ctx context.Context, state *scanState) func() error
|
||||
return s.ds.WithTx(func(tx model.DataStore) error {
|
||||
if state.changesDetected.Load() {
|
||||
start := time.Now()
|
||||
err := tx.GC(ctx, state.affectedLibIDs...)
|
||||
err := tx.GC(ctx)
|
||||
if err != nil {
|
||||
log.Error(ctx, "Scanner: Error running GC", err)
|
||||
return fmt.Errorf("running GC: %w", err)
|
||||
|
||||
@ -258,6 +258,6 @@ func (db *MockDataStore) Resource(ctx context.Context, m any) model.ResourceRepo
|
||||
}
|
||||
}
|
||||
|
||||
func (db *MockDataStore) GC(context.Context, ...int) error {
|
||||
func (db *MockDataStore) GC(context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user