Listenbrainz: skip tracks that do not have mbid instead of crashing. fixes #249

This commit is contained in:
emeric
2022-07-13 20:18:25 +02:00
parent 82dd6428f1
commit 7eb267652b
@@ -179,25 +179,32 @@ namespace Scrobbling::ListenBrainz
switch (type) switch (type)
{ {
case FeedbackType::Love: case FeedbackType::Love:
starredTrack.modify()->setScrobblingState(ScrobblingState::PendingAdd); if (starredTrack->getScrobblingState() != ScrobblingState::PendingAdd)
break; starredTrack.modify()->setScrobblingState(ScrobblingState::PendingAdd);
break;
case FeedbackType::Erase: case FeedbackType::Erase:
if (!recordingMBID) if (!recordingMBID)
{ {
LOG(DEBUG) << "Track has no recording MBID: erasing star"; LOG(DEBUG) << "Track has no recording MBID: erasing star";
starredTrack.remove(); starredTrack.remove();
} }
else else
{ {
// Send the erase order even if it is not on the remote LB server (it may be // Send the erase order even if it is not on the remote LB server (it may be
// queued for add, or not) // queued for add, or not)
starredTrack.modify()->setScrobblingState(ScrobblingState::PendingRemove); starredTrack.modify()->setScrobblingState(ScrobblingState::PendingRemove);
} }
break; break;
default: default:
throw Exception {"Unhandled feedback type"}; throw Exception {"Unhandled feedback type"};
}
if (!recordingMBID)
{
LOG(DEBUG) << "Track has no recording MBID: skipping";
return;
} }
const std::optional<UUID> listenBrainzToken {starredTrack->getUser()->getListenBrainzToken()}; const std::optional<UUID> listenBrainzToken {starredTrack->getUser()->getListenBrainzToken()};