Skip to content

Commit

Permalink
consider removable drives when checking for matching source during li…
Browse files Browse the repository at this point in the history
…brary cleanup
  • Loading branch information
mkortstiege authored and popcornmix committed Apr 22, 2015
1 parent e339f25 commit cef716c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions xbmc/video/VideoDatabase.cpp
Expand Up @@ -51,6 +51,7 @@
#include "settings/MediaSettings.h"
#include "settings/MediaSourceSettings.h"
#include "settings/Settings.h"
#include "storage/MediaManager.h"
#include "utils/StringUtils.h"
#include "guilib/LocalizeStrings.h"
#include "utils/TimeUtils.h"
Expand Down Expand Up @@ -7921,7 +7922,8 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se
}

std::string filesToTestForDelete;
VECSOURCES *videoSources = CMediaSourceSettings::Get().GetSources("video");
VECSOURCES videoSources(*CMediaSourceSettings::Get().GetSources("video"));
g_mediaManager.GetRemovableDrives(videoSources);

int total = m_pDS->num_rows();
int current = 0;
Expand All @@ -7944,7 +7946,7 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se
// remove optical, non-existing files, files with no matching source
bool bIsSource;
if (URIUtils::IsOnDVD(fullPath) || !CFile::Exists(fullPath, false) ||
CUtil::GetMatchingSource(fullPath, *videoSources, bIsSource) < 0)
CUtil::GetMatchingSource(fullPath, videoSources, bIsSource) < 0)
filesToTestForDelete += m_pDS->fv("files.idFile").get_asString() + ",";

if (handle == NULL && progress != NULL)
Expand Down Expand Up @@ -8244,7 +8246,9 @@ std::vector<int> CVideoDatabase::CleanMediaType(const std::string &mediaType, co
parentPathIdField.c_str(),
table.c_str(), cleanableFileIDs.c_str());

VECSOURCES *videoSources = CMediaSourceSettings::Get().GetSources("video");
VECSOURCES videoSources(*CMediaSourceSettings::Get().GetSources("video"));
g_mediaManager.GetRemovableDrives(videoSources);

// map of parent path ID to boolean pair (if not exists and user choice)
std::map<int, std::pair<bool, bool> > sourcePathsDeleteDecisions;
m_pDS2->query(sql.c_str());
Expand All @@ -8261,7 +8265,7 @@ std::vector<int> CVideoDatabase::CleanMediaType(const std::string &mediaType, co
GetSourcePath(parentPath, sourcePath, scanSettings);

bool bIsSourceName;
bool sourceNotFound = (CUtil::GetMatchingSource(parentPath, *videoSources, bIsSourceName) < 0);
bool sourceNotFound = (CUtil::GetMatchingSource(parentPath, videoSources, bIsSourceName) < 0);

if (sourceNotFound && sourcePath.empty())
sourcePath = parentPath;
Expand Down

0 comments on commit cef716c

Please sign in to comment.