Permalink
Browse files

videodb: add a delete trigger for the files table

  • Loading branch information...
Montellese committed Apr 17, 2015
1 parent 7f0425c commit 1e89519299e7a869fbdb4d133721ba56d02f821b
Showing with 7 additions and 17 deletions.
  1. +7 −17 xbmc/video/VideoDatabase.cpp
@@ -315,6 +315,12 @@ void CVideoDatabase::CreateAnalytics()
m_pDS->exec("CREATE TRIGGER delete_tag AFTER DELETE ON tag_link FOR EACH ROW BEGIN "
"DELETE FROM tag WHERE tag_id=old.tag_id AND tag_id NOT IN (SELECT DISTINCT tag_id FROM tag_link); "
"END");
m_pDS->exec("CREATE TRIGGER delete_file AFTER DELETE ON files FOR EACH ROW BEGIN "
"DELETE FROM bookmark WHERE idFile=old.idFile; "
"DELETE FROM settings WHERE idFile=old.idFile; "
"DELETE FROM stacktimes WHERE idFile=old.idFile; "
"DELETE FROM streamdetails WHERE idFile=old.idFile; "
"END");

CreateViews();
}
@@ -4674,7 +4680,7 @@ void CVideoDatabase::UpdateTables(int iVersion)

int CVideoDatabase::GetSchemaVersion() const
{
return 91;
return 92;
}

void CVideoDatabase::CleanupActorLinkTablePre91(const std::string &linkTable, const std::string &linkTableIdActor, const std::string &linkTableIdMedia, int idActor, const std::string &strActor)
@@ -7981,22 +7987,6 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se
CLog::Log(LOGDEBUG, "%s: Cleaning files table", __FUNCTION__);
sql = "DELETE FROM files WHERE idFile IN " + filesToDelete;
m_pDS->exec(sql.c_str());

CLog::Log(LOGDEBUG, "%s: Cleaning streamdetails table", __FUNCTION__);
sql = "DELETE FROM streamdetails WHERE idFile IN " + filesToDelete;
m_pDS->exec(sql.c_str());

CLog::Log(LOGDEBUG, "%s: Cleaning bookmark table", __FUNCTION__);
sql = "DELETE FROM bookmark WHERE idFile IN " + filesToDelete;
m_pDS->exec(sql.c_str());

CLog::Log(LOGDEBUG, "%s: Cleaning settings table", __FUNCTION__);
sql = "DELETE FROM settings WHERE idFile IN " + filesToDelete;
m_pDS->exec(sql.c_str());

CLog::Log(LOGDEBUG, "%s: Cleaning stacktimes table", __FUNCTION__);
sql = "DELETE FROM stacktimes WHERE idFile IN " + filesToDelete;
m_pDS->exec(sql.c_str());
}

if (!movieIDs.empty())

0 comments on commit 1e89519

Please sign in to comment.