Fixed bad optimize condition
This commit is contained in:
@@ -40,7 +40,7 @@ namespace
|
||||
Artist::pointer
|
||||
createArtist(Session& session, const MetaData::Artist& artistInfo)
|
||||
{
|
||||
Artist::pointer artist {session.create<Artist>(artistInfo.name)};
|
||||
Artist::pointer artist{ session.create<Artist>(artistInfo.name) };
|
||||
|
||||
if (artistInfo.mbid)
|
||||
artist.modify()->setMBID(*artistInfo.mbid);
|
||||
@@ -60,7 +60,7 @@ namespace
|
||||
}
|
||||
|
||||
// Sortname may have been updated
|
||||
if (artistInfo.sortName && *artistInfo.sortName != artist->getSortName() )
|
||||
if (artistInfo.sortName && *artistInfo.sortName != artist->getSortName())
|
||||
{
|
||||
artist.modify()->setSortName(*artistInfo.sortName);
|
||||
}
|
||||
@@ -185,7 +185,7 @@ namespace
|
||||
release.modify()->setTotalDisc(releaseInfo.mediumCount);
|
||||
if (releaseInfo.primaryType)
|
||||
{
|
||||
const ReleaseTypePrimary primaryType {convertReleaseTypePrimary(*releaseInfo.primaryType)};
|
||||
const ReleaseTypePrimary primaryType{ convertReleaseTypePrimary(*releaseInfo.primaryType) };
|
||||
if (release->getPrimaryType() != primaryType)
|
||||
release.modify()->setPrimaryType(primaryType);
|
||||
}
|
||||
@@ -263,7 +263,7 @@ namespace
|
||||
MetaData::ParserReadStyle
|
||||
getParserReadStyle()
|
||||
{
|
||||
std::string_view readStyle {Service<IConfig>::get()->getString("scanner-parser-read-style", "accurate")};
|
||||
std::string_view readStyle{ Service<IConfig>::get()->getString("scanner-parser-read-style", "accurate") };
|
||||
|
||||
if (readStyle == "fast")
|
||||
return MetaData::ParserReadStyle::Fast;
|
||||
@@ -272,15 +272,15 @@ namespace
|
||||
else if (readStyle == "accurate")
|
||||
return MetaData::ParserReadStyle::Accurate;
|
||||
|
||||
throw LmsException {"Invalid value for 'scanner-parser-read-style'"};
|
||||
throw LmsException{ "Invalid value for 'scanner-parser-read-style'" };
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace Scanner
|
||||
{
|
||||
ScanStepScanFiles::ScanStepScanFiles(InitParams& initParams)
|
||||
: ScanStepBase {initParams}
|
||||
, _metadataParser {MetaData::createParser(MetaData::ParserType::TagLib, getParserReadStyle())} // For now, always use TagLib
|
||||
: ScanStepBase{ initParams }
|
||||
, _metadataParser{ MetaData::createParser(MetaData::ParserType::TagLib, getParserReadStyle()) } // For now, always use TagLib
|
||||
{
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ namespace Scanner
|
||||
if (ec)
|
||||
{
|
||||
LMS_LOG(DBUPDATER, ERROR) << "Cannot process entry '" << path.string() << "': " << ec.message();
|
||||
context.stats.errors.emplace_back(ScanError {path, ScanErrorType::CannotReadFile, ec.message()});
|
||||
context.stats.errors.emplace_back(ScanError{ path, ScanErrorType::CannotReadFile, ec.message() });
|
||||
}
|
||||
else if (PathUtils::hasFileAnyExtension(path, _settings.supportedExtensions))
|
||||
{
|
||||
@@ -309,7 +309,7 @@ namespace Scanner
|
||||
_progressCallback(context.currentStepStats);
|
||||
|
||||
// optimize the database during scan (if we import a very large database, it may be too late to do it once at end)
|
||||
if ((context.stats.nbChanges() % 5'000) == 0)
|
||||
if ((context.currentStepStats.processedElems % 1'000) == 0)
|
||||
_db.getTLSSession().optimize();
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ namespace Scanner
|
||||
void
|
||||
ScanStepScanFiles::scanAudioFile(const std::filesystem::path& file, ScanContext& context)
|
||||
{
|
||||
ScanStats& stats {context.stats};
|
||||
ScanStats& stats{ context.stats };
|
||||
Wt::WDateTime lastWriteTime;
|
||||
try
|
||||
{
|
||||
@@ -336,10 +336,10 @@ namespace Scanner
|
||||
if (!context.forceScan)
|
||||
{
|
||||
// Skip file if last write is the same
|
||||
Database::Session& dbSession {_db.getTLSSession()};
|
||||
auto transaction {_db.getTLSSession().createSharedTransaction()};
|
||||
Database::Session& dbSession{ _db.getTLSSession() };
|
||||
auto transaction{ _db.getTLSSession().createSharedTransaction() };
|
||||
|
||||
const Track::pointer track {Track::findByPath(dbSession, file)};
|
||||
const Track::pointer track{ Track::findByPath(dbSession, file) };
|
||||
|
||||
if (track && track->getLastWriteTime().toTime_t() == lastWriteTime.toTime_t()
|
||||
&& track->getScanVersion() == _settings.scanVersion)
|
||||
@@ -349,7 +349,7 @@ namespace Scanner
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<MetaData::Track> trackInfo {_metadataParser->parse(file)};
|
||||
std::optional<MetaData::Track> trackInfo{ _metadataParser->parse(file) };
|
||||
if (!trackInfo)
|
||||
{
|
||||
context.stats.errors.emplace_back(file, ScanErrorType::CannotParseFile);
|
||||
@@ -358,19 +358,19 @@ namespace Scanner
|
||||
|
||||
stats.scans++;
|
||||
|
||||
Database::Session& dbSession {_db.getTLSSession()};
|
||||
auto uniqueTransaction {dbSession.createUniqueTransaction()};
|
||||
Database::Session& dbSession{ _db.getTLSSession() };
|
||||
auto uniqueTransaction{ dbSession.createUniqueTransaction() };
|
||||
|
||||
Track::pointer track {Track::findByPath(dbSession, file) };
|
||||
Track::pointer track{ Track::findByPath(dbSession, file) };
|
||||
|
||||
if (trackInfo->mbid && (!track || _settings.skipDuplicateMBID))
|
||||
{
|
||||
std::vector<Track::pointer> duplicateTracks {Track::findByMBID(dbSession, *trackInfo->mbid)};
|
||||
std::vector<Track::pointer> duplicateTracks{ Track::findByMBID(dbSession, *trackInfo->mbid) };
|
||||
|
||||
// find for existing MBIDs as the file may have just been moved
|
||||
if (!track && duplicateTracks.size() == 1)
|
||||
{
|
||||
Track::pointer otherTrack {duplicateTracks.front()};
|
||||
Track::pointer otherTrack{ duplicateTracks.front() };
|
||||
std::error_code ec;
|
||||
if (!std::filesystem::exists(otherTrack->getPath(), ec))
|
||||
{
|
||||
@@ -418,7 +418,7 @@ namespace Scanner
|
||||
track.remove();
|
||||
stats.deletions++;
|
||||
}
|
||||
stats.errors.emplace_back(ScanError {file, ScanErrorType::NoAudioTrack});
|
||||
stats.errors.emplace_back(ScanError{ file, ScanErrorType::NoAudioTrack });
|
||||
return;
|
||||
}
|
||||
if (trackInfo->duration == std::chrono::milliseconds::zero())
|
||||
@@ -431,7 +431,7 @@ namespace Scanner
|
||||
track.remove();
|
||||
stats.deletions++;
|
||||
}
|
||||
stats.errors.emplace_back(ScanError {file, ScanErrorType::BadDuration});
|
||||
stats.errors.emplace_back(ScanError{ file, ScanErrorType::BadDuration });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -525,7 +525,7 @@ namespace Scanner
|
||||
|
||||
track.modify()->setRecordingMBID(trackInfo->recordingMBID);
|
||||
track.modify()->setTrackMBID(trackInfo->mbid);
|
||||
if (auto trackFeatures {TrackFeatures::find(dbSession, track->getId())})
|
||||
if (auto trackFeatures{ TrackFeatures::find(dbSession, track->getId()) })
|
||||
trackFeatures.remove(); // TODO: only if MBID changed?
|
||||
track.modify()->setHasCover(trackInfo->hasCover);
|
||||
track.modify()->setCopyright(trackInfo->copyright);
|
||||
|
||||
Reference in New Issue
Block a user