Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[epg] fixed - delete tables that are no longer valid. fixed Delete() …

…method from the db, so it deletes the table instead of entries
  • Loading branch information...
commit b6e17f5572437f560bfbed66f6f1f13eefeaa355 1 parent e979ca9
Lars Op den Kamp opdenkamp authored
8 xbmc/epg/Epg.cpp
View
@@ -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;
+}
5 xbmc/epg/Epg.h
View
@@ -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);
10 xbmc/epg/EpgContainer.cpp
View
@@ -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 */
13 xbmc/epg/EpgDatabase.cpp
View
@@ -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)
10 xbmc/epg/EpgDatabase.h
View
@@ -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.
Please sign in to comment.
Something went wrong with that request. Please try again.