Do not drop all clusters when updating the scan settings
This commit is contained in:
@@ -80,10 +80,6 @@ ScanSettings::setClusterTypes(const std::set<std::string>& clusterTypeNames)
|
||||
bool needRescan = false;
|
||||
assert(session());
|
||||
|
||||
// Backup the old list
|
||||
std::vector<ClusterType::pointer> oldClusterTypes(_clusterTypes.begin(), _clusterTypes.end());
|
||||
|
||||
_clusterTypes.clear();
|
||||
// Create any missing cluster type
|
||||
for (auto clusterTypeName : clusterTypeNames)
|
||||
{
|
||||
@@ -98,13 +94,13 @@ ScanSettings::setClusterTypes(const std::set<std::string>& clusterTypeNames)
|
||||
}
|
||||
|
||||
// Delete no longer existing cluster types
|
||||
for (auto oldClusterType : oldClusterTypes)
|
||||
for (auto clusterType : _clusterTypes)
|
||||
{
|
||||
if (std::none_of(clusterTypeNames.begin(), clusterTypeNames.end(),
|
||||
[oldClusterType](const std::string& name) { return name == oldClusterType->getName(); }))
|
||||
[clusterType](const std::string& name) { return name == clusterType->getName(); }))
|
||||
{
|
||||
LMS_LOG(DB, INFO) << "Deleting cluster type " << oldClusterType->getName();
|
||||
oldClusterType.remove();
|
||||
LMS_LOG(DB, INFO) << "Deleting cluster type " << clusterType->getName();
|
||||
clusterType.remove();
|
||||
needRescan = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,6 +345,8 @@ MediaScanner::refreshScanSettings()
|
||||
|
||||
auto scanSettings = ScanSettings::get(_db.getSession());
|
||||
|
||||
LMS_LOG(DBUPDATER, INFO) << "Using scan settings version " << scanSettings->getScanVersion();
|
||||
|
||||
_scanVersion = scanSettings->getScanVersion();
|
||||
_startTime = scanSettings->getUpdateStartTime();
|
||||
_updatePeriod = scanSettings->getUpdatePeriod();
|
||||
@@ -607,21 +609,18 @@ checkFile(const boost::filesystem::path& p, boost::filesystem::path mediaDirecto
|
||||
if (!boost::filesystem::exists( p )
|
||||
|| !boost::filesystem::is_regular( p ) )
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO) << "Missing file '" << p.string() << "'";
|
||||
LMS_LOG(DBUPDATER, INFO) << "Removing '" << p.string() << "': missing";
|
||||
status = false;
|
||||
}
|
||||
else
|
||||
else if (!isPathInParentPath(p, mediaDirectory))
|
||||
{
|
||||
if (!isPathInParentPath(p, mediaDirectory))
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO) << "File '" << p.string() << "' is out of media directory '";
|
||||
status = false;
|
||||
}
|
||||
else if (!isFileSupported(p, extensions))
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO) << "File format no longer supported for '" << p.string() << "'";
|
||||
status = false;
|
||||
}
|
||||
LMS_LOG(DBUPDATER, INFO) << "Removing '" << p.string() << "': out of media directory";
|
||||
status = false;
|
||||
}
|
||||
else if (!isFileSupported(p, extensions))
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO) << "Removing '" << p.string() << "': file format no longer handled";
|
||||
status = false;
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -632,7 +631,6 @@ checkFile(const boost::filesystem::path& p, boost::filesystem::path mediaDirecto
|
||||
LMS_LOG(DBUPDATER, ERROR) << "Caught exception while checking file '" << p.string() << "': " << e.what();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -401,6 +401,7 @@ LmsApplication::handleAuthEvent(void)
|
||||
notifyMsg(Wt::WString::tr("Lms.Admin.Database.scan-complete")
|
||||
.arg(static_cast<unsigned>(stats.nbFiles()))
|
||||
.arg(static_cast<unsigned>(stats.additions))
|
||||
.arg(static_cast<unsigned>(stats.updates))
|
||||
.arg(static_cast<unsigned>(stats.deletions))
|
||||
.arg(static_cast<unsigned>(stats.nbDuplicates()))
|
||||
.arg(static_cast<unsigned>(stats.nbErrors())));
|
||||
|
||||
Reference in New Issue
Block a user