From e3dc1887730cb019a91e74ad8a133a31839dbf56 Mon Sep 17 00:00:00 2001 From: Eric Munson Date: Tue, 27 May 2025 18:17:50 -0400 Subject: [PATCH] fix(subsonic): skip bookmarks for missing items instead of failing (#580) Currently if a bookmark exists for an item that does not exist in the db, either because it has been removed or it never did, the user is prevented from retrieving any bookmarks. We can be in this state if media has moved or been deleted, but also because the createBookmark endpoint does not verify the item id provided. This patch makes the getBookmarks endpoint ignore bookmarks for missing items. Fixes: https://github.com/sentriz/gonic/issues/578 Signed-off-by: Eric B Munson --- server/ctrlsubsonic/handlers_bookmark.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/ctrlsubsonic/handlers_bookmark.go b/server/ctrlsubsonic/handlers_bookmark.go index d1e4464..d1ea56e 100644 --- a/server/ctrlsubsonic/handlers_bookmark.go +++ b/server/ctrlsubsonic/handlers_bookmark.go @@ -45,7 +45,12 @@ func (c *Controller) ServeGetBookmarks(r *http.Request) *spec.Response { Find(&track, "id=?", bookmark.EntryID). Error if err != nil { - return spec.NewError(10, "finding entry: %v", err) + /* + * We get here if we have a bookmark for a Track that no longer exists, this should be an + * error because tracks can disappear if the files are moved etc. Just skip the not found + * entry and move on. + */ + continue } respBookmark.Entry = spec.NewTrackByTags(&track, track.Album) case specid.PodcastEpisode: @@ -55,7 +60,8 @@ func (c *Controller) ServeGetBookmarks(r *http.Request) *spec.Response { Find(&podcastEpisode, "id=?", bookmark.EntryID). Error if err != nil { - return spec.NewError(10, "finding entry: %v", err) + /* Same as with the missing track above. */ + continue } respBookmark.Entry = spec.NewTCPodcastEpisode(&podcastEpisode) default: