Skip to content

Commit

Permalink
videodb: cleanup paramters of CleanDatabase()
Browse files Browse the repository at this point in the history
  • Loading branch information
Montellese committed Feb 16, 2015
1 parent b5dd931 commit 6402db2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
5 changes: 4 additions & 1 deletion xbmc/Application.cpp
Expand Up @@ -4978,7 +4978,10 @@ void CApplication::StartVideoCleanup(bool userInitiated /* = true */)
return;

if (userInitiated)
m_videoInfoScanner->CleanDatabase(NULL, NULL, true);
{
std::set<int> paths;
m_videoInfoScanner->CleanDatabase(NULL, paths, userInitiated);
}
else
{
m_videoInfoScanner->ShowDialog(false);
Expand Down
13 changes: 3 additions & 10 deletions xbmc/video/VideoDatabase.cpp
Expand Up @@ -7816,7 +7816,7 @@ void CVideoDatabase::GetMusicVideoDirectorsByName(const std::string& strSearch,
}
}

void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const set<int>* paths, bool showProgress)
void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const set<int>& paths, bool showProgress)
{
CGUIDialogProgress *progress=NULL;
try
Expand All @@ -7832,17 +7832,10 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se

// find all the files
std::string sql = "SELECT files.idFile, files.strFileName, path.strPath FROM files, path WHERE files.idPath = path.idPath";
if (paths)
if (!paths.empty())
{
if (paths->empty())
{
RollbackTransaction();
ANNOUNCEMENT::CAnnouncementManager::Get().Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnCleanFinished");
return;
}

std::string strPaths;
for (std::set<int>::const_iterator it = paths->begin(); it != paths->end(); ++it)
for (std::set<int>::const_iterator it = paths.begin(); it != paths.end(); ++it)
strPaths += StringUtils::Format(",%i", *it);
sql += PrepareSQL(" AND path.idPath IN (%s)", strPaths.substr(1).c_str());
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/video/VideoDatabase.h
Expand Up @@ -668,7 +668,7 @@ class CVideoDatabase : public CDatabase
bool HasContent(VIDEODB_CONTENT_TYPE type);
bool HasSets() const;

void CleanDatabase(CGUIDialogProgressBarHandle* handle=NULL, const std::set<int>* paths=NULL, bool showProgress=true);
void CleanDatabase(CGUIDialogProgressBarHandle* handle = NULL, const std::set<int>& paths = std::set<int>(), bool showProgress = true);

/*! \brief Add a file to the database, if necessary
If the file is already in the database, we simply return its id.
Expand Down
7 changes: 4 additions & 3 deletions xbmc/video/VideoInfoScanner.cpp
Expand Up @@ -89,7 +89,8 @@ namespace VIDEO
// check if we only need to perform a cleaning
if (m_bClean && m_pathsToScan.empty())
{
CleanDatabase(m_handle, NULL, false);
std::set<int> paths;
CleanDatabase(m_handle, paths, false);

if (m_handle)
m_handle->MarkFinished();
Expand Down Expand Up @@ -147,7 +148,7 @@ namespace VIDEO
if (!bCancelled)
{
if (m_bClean)
CleanDatabase(m_handle,&m_pathsToClean, false);
CleanDatabase(m_handle, m_pathsToClean, false);
else
{
if (m_handle)
Expand Down Expand Up @@ -244,7 +245,7 @@ namespace VIDEO
StopThread(false);
}

void CVideoInfoScanner::CleanDatabase(CGUIDialogProgressBarHandle* handle /*= NULL */, const set<int>* paths /*= NULL */, bool showProgress /*= true */)
void CVideoInfoScanner::CleanDatabase(CGUIDialogProgressBarHandle* handle /* = NULL */, const set<int>& paths /* = set<int> */, bool showProgress /* = true */)
{
m_bRunning = true;
m_database.Open();
Expand Down
2 changes: 1 addition & 1 deletion xbmc/video/VideoInfoScanner.h
Expand Up @@ -61,7 +61,7 @@ namespace VIDEO
void Start(const std::string& strDirectory, bool scanAll = false);
void StartCleanDatabase();
bool IsScanning();
void CleanDatabase(CGUIDialogProgressBarHandle* handle=NULL, const std::set<int>* paths=NULL, bool showProgress=true);
void CleanDatabase(CGUIDialogProgressBarHandle* handle = NULL, const std::set<int>& paths = std::set<int>(), bool showProgress = true);
void Stop();

//! \brief Set whether or not to show a progress dialog
Expand Down

0 comments on commit 6402db2

Please sign in to comment.