Skip to content

Commit

Permalink
[PVR] GetRecordings: Do not delete recordings for failed clients.
Browse files Browse the repository at this point in the history
  • Loading branch information
ksooo committed Nov 4, 2020
1 parent 36962a8 commit 05626b2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
15 changes: 10 additions & 5 deletions xbmc/pvr/addons/PVRClients.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,16 @@ PVR_ERROR CPVRClients::GetTimerTypes(std::vector<std::shared_ptr<CPVRTimerType>>
});
}

PVR_ERROR CPVRClients::GetRecordings(CPVRRecordings* recordings, bool deleted)
{
return ForCreatedClients(__FUNCTION__, [recordings, deleted](const std::shared_ptr<CPVRClient>& client) {
return client->GetRecordings(recordings, deleted);
});
PVR_ERROR CPVRClients::GetRecordings(CPVRRecordings* recordings,
bool deleted,
std::vector<int>& failedClients)
{
return ForCreatedClients(
__FUNCTION__,
[recordings, deleted](const std::shared_ptr<CPVRClient>& client) {
return client->GetRecordings(recordings, deleted);
},
failedClients);
}

PVR_ERROR CPVRClients::DeleteAllRecordingsFromTrash()
Expand Down
5 changes: 4 additions & 1 deletion xbmc/pvr/addons/PVRClients.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,12 @@ namespace PVR
* @brief Get all recordings from clients
* @param recordings Store the recordings in this container.
* @param deleted If true, return deleted recordings, return not deleted recordings otherwise.
* @param failedClients in case of errors will contain the ids of the clients for which the recordings could not be obtained.
* @return PVR_ERROR_NO_ERROR if the operation succeeded, the respective PVR_ERROR value otherwise.
*/
PVR_ERROR GetRecordings(CPVRRecordings* recordings, bool deleted);
PVR_ERROR GetRecordings(CPVRRecordings* recordings,
bool deleted,
std::vector<int>& failedClients);

/*!
* @brief Delete all "soft" deleted recordings permanently on the backend.
Expand Down
8 changes: 5 additions & 3 deletions xbmc/pvr/recordings/PVRRecordings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ void CPVRRecordings::UpdateFromClients()
for (const auto& recording : m_recordings)
recording.second->SetDirty(true);

CServiceBroker::GetPVRManager().Clients()->GetRecordings(this, false);
CServiceBroker::GetPVRManager().Clients()->GetRecordings(this, true);
std::vector<int> failedClients;
CServiceBroker::GetPVRManager().Clients()->GetRecordings(this, false, failedClients);
CServiceBroker::GetPVRManager().Clients()->GetRecordings(this, true, failedClients);

// remove recordings that were deleted at the backend
for (auto it = m_recordings.begin(); it != m_recordings.end();)
{
if ((*it).second->IsDirty())
if ((*it).second->IsDirty() && std::find(failedClients.begin(), failedClients.end(),
(*it).second->ClientID()) == failedClients.end())
it = m_recordings.erase(it);
else
++it;
Expand Down

0 comments on commit 05626b2

Please sign in to comment.