Big changes
This commit is contained in:
@@ -56,14 +56,22 @@ type Syncer struct {
|
||||
// is borrowed instead.
|
||||
serviceCred emby.Credentials
|
||||
|
||||
mu sync.Mutex
|
||||
running bool
|
||||
mu sync.Mutex
|
||||
running bool
|
||||
afterSync func()
|
||||
}
|
||||
|
||||
func NewSyncer(embyClient *emby.Client, st *store.Store, serviceCred emby.Credentials, log *slog.Logger) *Syncer {
|
||||
return &Syncer{emby: embyClient, store: st, serviceCred: serviceCred, log: log}
|
||||
}
|
||||
|
||||
// SetAfterSync installs the inexpensive invalidation callback used by derived data.
|
||||
func (s *Syncer) SetAfterSync(callback func()) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.afterSync = callback
|
||||
}
|
||||
|
||||
// Result summarises one import.
|
||||
type Result struct {
|
||||
Kind string `json:"kind"`
|
||||
@@ -150,6 +158,12 @@ func (s *Syncer) Sync(ctx context.Context, kind, trigger string) (Result, error)
|
||||
"kind", kind, "trigger", trigger, "seen", result.Seen,
|
||||
"upserted", result.Upserted, "removed", result.Removed,
|
||||
"duration", result.Duration.Round(time.Millisecond))
|
||||
s.mu.Lock()
|
||||
afterSync := s.afterSync
|
||||
s.mu.Unlock()
|
||||
if afterSync != nil {
|
||||
afterSync()
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -345,5 +359,12 @@ func searchText(parsed syncItem) string {
|
||||
parts = append(parts, strconv.Itoa(*parsed.ProductionYear))
|
||||
}
|
||||
parts = append(parts, parsed.Genres...)
|
||||
// Studios too, so "A24" or "Pixar" finds a shelf's worth of titles. Existing rows
|
||||
// keep their old text until the next full import rewrites them.
|
||||
for _, studio := range parsed.Studios {
|
||||
if studio.Name != "" {
|
||||
parts = append(parts, studio.Name)
|
||||
}
|
||||
}
|
||||
return strings.Join(parts, " ")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user