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