aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Op den Kamp <lars@opdenkamp.eu>2012-12-07 02:10:33 +0100
committerLars Op den Kamp <lars@opdenkamp.eu>2012-12-07 02:30:44 +0100
commitb6e17f5572437f560bfbed66f6f1f13eefeaa355 (patch)
tree480f0ffdf8a458363763a7b2d75b9d6a2fadb400
parente979ca980745eda50d5506431e379dedf76466f9 (diff)
[epg] fixed - delete tables that are no longer valid. fixed Delete() method from the db, so it deletes the table instead of entries
-rw-r--r--xbmc/epg/Epg.cpp8
-rw-r--r--xbmc/epg/Epg.h5
-rw-r--r--xbmc/epg/EpgContainer.cpp10
-rw-r--r--xbmc/epg/EpgDatabase.cpp13
-rw-r--r--xbmc/epg/EpgDatabase.h10
5 files changed, 29 insertions, 17 deletions
diff --git a/xbmc/epg/Epg.cpp b/xbmc/epg/Epg.cpp
index 353f968b9b..752214cdbe 100644
--- a/xbmc/epg/Epg.cpp
+++ b/xbmc/epg/Epg.cpp
@@ -901,3 +901,11 @@ bool CEpg::NeedsSave(void) const
CSingleLock lock(m_critSection);
return !m_changedTags.empty() || !m_deletedTags.empty() || m_bChanged;
}
+
+bool CEpg::IsValid(void) const
+{
+ CSingleLock lock(m_critSection);
+ if (ScraperName() == "client")
+ return Channel().get() != NULL;
+ return true;
+}
diff --git a/xbmc/epg/Epg.h b/xbmc/epg/Epg.h
index b22206351e..55e4d72d2c 100644
--- a/xbmc/epg/Epg.h
+++ b/xbmc/epg/Epg.h
@@ -299,6 +299,11 @@ namespace EPG
size_t Size(void) const;
bool NeedsSave(void) const;
+
+ /*!
+ * @return True when this EPG is valid and can be updated, false otherwise
+ */
+ bool IsValid(void) const;
protected:
CEpg(void);
diff --git a/xbmc/epg/EpgContainer.cpp b/xbmc/epg/EpgContainer.cpp
index 3e8c84b454..43a2df04c5 100644
--- a/xbmc/epg/EpgContainer.cpp
+++ b/xbmc/epg/EpgContainer.cpp
@@ -382,6 +382,7 @@ bool CEpgContainer::DeleteEpg(const CEpg &epg, bool bDeleteFromDatabase /* = fal
if (it == m_epgs.end())
return false;
+ CLog::Log(LOGDEBUG, "deleting EPG table %s (%d)", epg.Name().c_str(), epg.EpgID());
if (bDeleteFromDatabase && !m_bIgnoreDbForClient && m_database.IsOpen())
m_database.Delete(*it->second);
@@ -490,6 +491,8 @@ bool CEpgContainer::UpdateEPG(bool bOnlyPending /* = false */)
return false;
}
+ vector<CEpg*> invalidTables;
+
/* load or update all EPG tables */
CEpg *epg;
unsigned int iCounter(0);
@@ -509,9 +512,14 @@ bool CEpgContainer::UpdateEPG(bool bOnlyPending /* = false */)
UpdateProgressDialog(++iCounter, m_epgs.size(), epg->Name());
if ((!bOnlyPending || epg->UpdatePending()) && epg->Update(start, end, m_iUpdateTime, bOnlyPending))
- ++iUpdatedTables;
+ iUpdatedTables++;
+ else if (!epg->IsValid())
+ invalidTables.push_back(epg);
}
+ for (vector<CEpg*>::iterator it = invalidTables.begin(); it != invalidTables.end(); it++)
+ DeleteEpg(**it, true);
+
if (bInterrupted)
{
/* the update has been interrupted. try again later */
diff --git a/xbmc/epg/EpgDatabase.cpp b/xbmc/epg/EpgDatabase.cpp
index 97854ed305..65a598486b 100644
--- a/xbmc/epg/EpgDatabase.cpp
+++ b/xbmc/epg/EpgDatabase.cpp
@@ -160,26 +160,19 @@ bool CEpgDatabase::DeleteEpg(void)
return bReturn;
}
-bool CEpgDatabase::Delete(const CEpg &table, const time_t start /* = 0 */, const time_t end /* = 0 */)
+bool CEpgDatabase::Delete(const CEpg &table)
{
/* invalid channel */
if (table.EpgID() <= 0)
{
- CLog::Log(LOGERROR, "EpgDB - %s - invalid channel id: %d",
- __FUNCTION__, table.EpgID());
+ CLog::Log(LOGERROR, "EpgDB - %s - invalid channel id: %d", __FUNCTION__, table.EpgID());
return false;
}
CStdString strWhereClause;
strWhereClause = FormatSQL("idEpg = %u", table.EpgID());
- if (start != 0)
- strWhereClause.append(FormatSQL(" AND iStartTime >= %u", start).c_str());
-
- if (end != 0)
- strWhereClause.append(FormatSQL(" AND iEndTime <= %u", end).c_str());
-
- return DeleteValues("epgtags", strWhereClause);
+ return DeleteValues("epg", strWhereClause);
}
bool CEpgDatabase::DeleteOldEpgEntries(void)
diff --git a/xbmc/epg/EpgDatabase.h b/xbmc/epg/EpgDatabase.h
index 77d930460b..1360989a29 100644
--- a/xbmc/epg/EpgDatabase.h
+++ b/xbmc/epg/EpgDatabase.h
@@ -71,13 +71,11 @@ namespace EPG
virtual bool DeleteEpg(void);
/*!
- * @brief Erase all EPG entries for a table.
- * @param table The table to remove the EPG entries for.
- * @param start Remove entries after this time if set.
- * @param end Remove entries before this time if set.
- * @return True if the entries were removed successfully, false otherwise.
+ * @brief Delete an EPG table.
+ * @param table The table to remove.
+ * @return True if the table was removed successfully, false otherwise.
*/
- virtual bool Delete(const CEpg &table, const time_t start = 0, const time_t end = 0);
+ virtual bool Delete(const CEpg &table);
/*!
* @brief Erase all EPG entries older than 1 day.