Skip to content

Commit e3dc188

Browse files
kherssentriz
authored andcommitted
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: #578 Signed-off-by: Eric B Munson <[email protected]>
1 parent 7b19101 commit e3dc188

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

server/ctrlsubsonic/handlers_bookmark.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ func (c *Controller) ServeGetBookmarks(r *http.Request) *spec.Response {
4545
Find(&track, "id=?", bookmark.EntryID).
4646
Error
4747
if err != nil {
48-
return spec.NewError(10, "finding entry: %v", err)
48+
/*
49+
* We get here if we have a bookmark for a Track that no longer exists, this should be an
50+
* error because tracks can disappear if the files are moved etc. Just skip the not found
51+
* entry and move on.
52+
*/
53+
continue
4954
}
5055
respBookmark.Entry = spec.NewTrackByTags(&track, track.Album)
5156
case specid.PodcastEpisode:
@@ -55,7 +60,8 @@ func (c *Controller) ServeGetBookmarks(r *http.Request) *spec.Response {
5560
Find(&podcastEpisode, "id=?", bookmark.EntryID).
5661
Error
5762
if err != nil {
58-
return spec.NewError(10, "finding entry: %v", err)
63+
/* Same as with the missing track above. */
64+
continue
5965
}
6066
respBookmark.Entry = spec.NewTCPodcastEpisode(&podcastEpisode)
6167
default:

0 commit comments

Comments
 (0)