Skip to content

Commit

Permalink
Don't show an alert when removing missing items
Browse files Browse the repository at this point in the history
When transitioning to the new schema, you'll likely get albums that
don't exist, though we try to update as soon as possible when the artist
album list is pulled. My guess is a race condition between getting the
album list from the server and the cached albums from Core Data.

The easiest workaround is to just not show this message.
  • Loading branch information
NattyNarwhal committed Nov 14, 2023
1 parent 5655278 commit 074e8aa
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions Submariner/SBSubsonicParsingOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,27 @@ class SBSubsonicParsingOperation: SBOperation, XMLParserDelegate {
return
}

if let currentPlaylistID = self.currentPlaylistID, let playlistToDelete = fetchPlaylist(id: currentPlaylistID) {
threadedContext.delete(playlistToDelete)
} else if let currentArtistID = self.currentArtistID, let artistToDelete = fetchArtist(id: currentArtistID) {
threadedContext.delete(artistToDelete)
} else if let currentAlbumID = self.currentAlbumID, let albumToDelete = fetchAlbum(id: currentAlbumID) {
threadedContext.delete(albumToDelete)
if let currentPlaylistID = self.currentPlaylistID {
logger.info("Didn't find playlist on server w/ ID of \(currentPlaylistID, privacy: .public)")
if let playlistToDelete = fetchPlaylist(id: currentPlaylistID) {
logger.info("Removing playlist that wasn't found on server w/ ID of \(currentPlaylistID, privacy: .public)")
threadedContext.delete(playlistToDelete)
}
return
} else if let currentArtistID = self.currentArtistID {
logger.info("Didn't find artist on server w/ ID of \(currentArtistID, privacy: .public)")
if let artistToDelete = fetchArtist(id: currentArtistID) {
logger.info("Removing artist that wasn't found on server w/ ID of \(currentArtistID, privacy: .public)")
threadedContext.delete(artistToDelete)
}
return
} else if let currentAlbumID = self.currentAlbumID {
logger.info("Didn't find album on server w/ ID of \(currentAlbumID, privacy: .public)")
if let albumToDelete = fetchAlbum(id: currentAlbumID) {
logger.info("Removing album that wasn't found on server w/ ID of \(currentAlbumID, privacy: .public)")
threadedContext.delete(albumToDelete)
}
return
}
// XXX: Cover, podcast, track? Do we need to remove it from any sets?
}
Expand Down

0 comments on commit 074e8aa

Please sign in to comment.