diff options
author | Kai Sommerfeld <kai.sommerfeld@gmx.com> | 2020-12-22 18:04:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-22 18:04:17 +0100 |
commit | 95ec740bd9f1bf1a825d57c0f0b67e690f430e29 (patch) | |
tree | efe59c21be6cd3d75cf542e4f568e5a94970c14f | |
parent | 53f8b1697625223b95af606cb193842c0431ca68 (diff) | |
parent | 91608d89db387b0ce9932d2d002b6eaf1a526267 (diff) |
Merge pull request #18970 from ksooo/pvr-fix-lastepgscan
[PVR] Fix EPG last scan time handling.
-rw-r--r-- | xbmc/pvr/epg/Epg.cpp | 16 | ||||
-rw-r--r-- | xbmc/pvr/epg/EpgDatabase.cpp | 20 | ||||
-rw-r--r-- | xbmc/pvr/epg/EpgDatabase.h | 7 |
3 files changed, 42 insertions, 1 deletions
diff --git a/xbmc/pvr/epg/Epg.cpp b/xbmc/pvr/epg/Epg.cpp index 1c8972994c..9b55122b93 100644 --- a/xbmc/pvr/epg/Epg.cpp +++ b/xbmc/pvr/epg/Epg.cpp @@ -260,6 +260,17 @@ bool CPVREpg::Update(time_t start, bool bGrabSuccess = true; bool bUpdate = false; + if (!m_lastScanTime.IsValid()) + { + database->GetLastEpgScanTime(m_iEpgID, &m_lastScanTime); + + if (!m_lastScanTime.IsValid()) + { + m_lastScanTime.SetFromUTCDateTime(time_t(0)); + m_bUpdateLastScanTime = true; + } + } + /* clean up if needed */ Cleanup(iPastDays); @@ -341,6 +352,9 @@ bool CPVREpg::QueueDeleteQueries(const std::shared_ptr<CPVREpgDatabase>& databas // delete own epg db entry database->QueueDeleteEpgQuery(*this); + // delete last scan time db entry for this epg + database->QueueDeleteLastEpgScanTimeQuery(*this); + // delete all tags for this epg from db m_tags.QueueDelete(); @@ -518,7 +532,7 @@ bool CPVREpg::UpdatePending() const bool CPVREpg::NeedsSave() const { CSingleLock lock(m_critSection); - return m_bChanged || m_tags.NeedsSave(); + return m_bChanged || m_bUpdateLastScanTime || m_tags.NeedsSave(); } bool CPVREpg::IsValid() const diff --git a/xbmc/pvr/epg/EpgDatabase.cpp b/xbmc/pvr/epg/EpgDatabase.cpp index b0e10e8baa..16e1b203d5 100644 --- a/xbmc/pvr/epg/EpgDatabase.cpp +++ b/xbmc/pvr/epg/EpgDatabase.cpp @@ -1008,6 +1008,26 @@ bool CPVREpgDatabase::QueuePersistLastEpgScanTimeQuery(int iEpgId, const CDateTi return QueueInsertQuery(strQuery); } +bool CPVREpgDatabase::QueueDeleteLastEpgScanTimeQuery(const CPVREpg& table) +{ + if (table.EpgID() <= 0) + { + CLog::LogF(LOGERROR, "Invalid EPG id: {}", table.EpgID()); + return false; + } + + Filter filter; + + CSingleLock lock(m_critSection); + filter.AppendWhere(PrepareSQL("idEpg = %u", table.EpgID())); + + std::string strQuery; + if (BuildSQL(PrepareSQL("DELETE FROM %s ", "lastepgscan"), filter, strQuery)) + return QueueDeleteQuery(strQuery); + + return false; +} + int CPVREpgDatabase::Persist(const CPVREpg& epg, bool bQueueWrite) { int iReturn = -1; diff --git a/xbmc/pvr/epg/EpgDatabase.h b/xbmc/pvr/epg/EpgDatabase.h index a0ab972d59..65ad169115 100644 --- a/xbmc/pvr/epg/EpgDatabase.h +++ b/xbmc/pvr/epg/EpgDatabase.h @@ -237,6 +237,13 @@ namespace PVR bool QueuePersistLastEpgScanTimeQuery(int iEpgId, const CDateTime& lastScanTime); /*! + * @brief Write the query to delete the last scan time for the given EPG to db query queue. + * @param iEpgId The table to delete the time for. + * @return True on success, false otherwise. + */ + bool QueueDeleteLastEpgScanTimeQuery(const CPVREpg& table); + + /*! * @brief Persist an EPG table. It's entries are not persisted. * @param epg The table to persist. * @param bQueueWrite If true, don't execute the query immediately but queue it. |