This commit is contained in:
ponzischeme89
2026-08-20 07:54:03 +12:00
parent 769fe01c84
commit 434371e9cf
37 changed files with 1767 additions and 102 deletions
+10 -14
View File
@@ -260,7 +260,16 @@ func (s *Server) handleAdminHeroPolicy(w http.ResponseWriter, r *http.Request) {
writeError(w, http.StatusInternalServerError, "could not save hero policy")
return
}
s.invalidateAllHomeCaches(r.Context())
// No cache sweep. The hero revision is part of the home and section-hero cache keys,
// so the entries built under the policy just replaced are already unreachable and age
// out on their own TTL; this only drops *this* instance's copy of the document, which
// is what makes the operator's own next read the answer they just saved rather than
// the one they replaced.
//
// It used to call InvalidateUser for every account in the house, which threw away
// every cached item lookup, image and row the household had in order to change four
// cards — so a hero edit made the next launcher on every set rebuild from Emby.
s.heroPolicy.invalidate()
writeJSON(w, http.StatusOK, map[string]any{"saved": true})
}
@@ -277,16 +286,3 @@ func uniqueHeroIDs(ids []string) []string {
}
return out
}
func (s *Server) invalidateAllHomeCaches(ctx context.Context) {
users, err := s.store.KnownUsers(ctx)
if err != nil {
s.loggerFor(ctx).Warn("hero cache invalidation could not list users", "error", err)
return
}
for _, user := range users {
if err := s.cache.InvalidateUser(ctx, user.ID); err != nil {
s.loggerFor(ctx).Warn("hero cache invalidation failed", "user", user.ID, "error", err)
}
}
}