diff --git a/internal/api/handlers/library_collections.go b/internal/api/handlers/library_collections.go index e8dbb359..25d8ce7a 100644 --- a/internal/api/handlers/library_collections.go +++ b/internal/api/handlers/library_collections.go @@ -130,7 +130,14 @@ func (h *LibraryCollectionHandler) storeBundledTemplatePoster( posterPath, ) if err != nil || !stored { - return false, storedPath, thumbhash, err + if err != nil { + slog.Warn("failed to store bundled template poster", + "collection_id", collectionID, + "poster_path", posterPath, + "error", err, + ) + } + return false, storedPath, thumbhash, nil } notAutoGenerated := false @@ -144,7 +151,13 @@ func (h *LibraryCollectionHandler) storeBundledTemplatePoster( input.PosterFromTemplate = &fromTemplate } if err := h.repo.Update(ctx, input); err != nil { - return false, "", "", fmt.Errorf("updating bundled poster path: %w", err) + slog.Warn("failed to persist bundled template poster", + "collection_id", collectionID, + "poster_path", posterPath, + "stored_path", storedPath, + "error", err, + ) + return false, "", "", nil } return true, storedPath, thumbhash, nil } diff --git a/internal/api/handlers/user_collection_imports.go b/internal/api/handlers/user_collection_imports.go index 8891d43b..3674450b 100644 --- a/internal/api/handlers/user_collection_imports.go +++ b/internal/api/handlers/user_collection_imports.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io/fs" + "log/slog" "net/http" "strings" "time" @@ -270,7 +271,14 @@ func (h *UserCollectionImportHandler) storeBundledTemplatePoster( posterPath, ) if err != nil || !stored { - return err + if err != nil { + slog.Warn("failed to store bundled user collection poster", + "collection_id", collection.ID, + "poster_path", posterPath, + "error", err, + ) + } + return nil } if err := store.UpdateCollection(r.Context(), userstore.UpdateCollectionInput{ @@ -279,7 +287,13 @@ func (h *UserCollectionImportHandler) storeBundledTemplatePoster( PosterURL: &storedPath, PosterThumbhash: &thumbhash, }); err != nil { - return fmt.Errorf("persisting template poster: %w", err) + slog.Warn("failed to persist bundled user collection poster", + "collection_id", collection.ID, + "poster_path", posterPath, + "stored_path", storedPath, + "error", err, + ) + return nil } collection.PosterURL = storedPath collection.PosterThumbhash = thumbhash diff --git a/internal/usercollections/sync.go b/internal/usercollections/sync.go index 7624329e..f1cf3007 100644 --- a/internal/usercollections/sync.go +++ b/internal/usercollections/sync.go @@ -243,8 +243,12 @@ func (s *Service) filterByLibraries(ctx context.Context, matched []userstore.Col // content_id for each, and produces deduped, position-numbered replacements // plus an unmatched count. Shared by all three source backends. func resolveMatchedWithLimit(total int, limit *int, resolve func(i int) string) ([]userstore.CollectionItemReplacement, int, int) { - matched := make([]userstore.CollectionItemReplacement, 0, total) - seen := make(map[string]struct{}, total) + capacity := total + if limit != nil && *limit > 0 && *limit < total { + capacity = *limit + } + matched := make([]userstore.CollectionItemReplacement, 0, capacity) + seen := make(map[string]struct{}, capacity) unmatched := 0 scanned := 0 for i := 0; i < total; i++ {