Removed orphan items after scan, make multi tag values work again
This commit is contained in:
@@ -185,7 +185,8 @@ Grabber::getFromTrack(Wt::Dbo::Session& session, Database::IdType trackId, std::
|
||||
|
||||
if (hasCover)
|
||||
cover = getFromTrack(trackPath);
|
||||
else
|
||||
|
||||
if (!cover)
|
||||
cover = getFromDirectory(trackPath.parent_path());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ class Track : public Wt::Dbo::Dbo<Track>
|
||||
std::vector<unsigned char> _fileChecksum;
|
||||
Wt::WDateTime _fileLastWrite;
|
||||
Wt::WDateTime _fileAdded;
|
||||
bool _hasCover;
|
||||
bool _hasCover = false;
|
||||
std::string _MBID; // Musicbrainz Identifier
|
||||
std::string _copyright;
|
||||
std::string _copyrightURL;
|
||||
|
||||
@@ -205,8 +205,13 @@ TagLibParser::parse(const boost::filesystem::path& p, bool debug)
|
||||
else if (_clusterTypeNames.find(tag) != _clusterTypeNames.end())
|
||||
{
|
||||
std::set<std::string> clusterNames;
|
||||
for (const auto& value : values)
|
||||
clusterNames.insert(value.to8Bit(true));
|
||||
for (const auto& valueList : values)
|
||||
{
|
||||
auto values = splitString(valueList.to8Bit(), "/,;");
|
||||
|
||||
for (auto value : values)
|
||||
clusterNames.insert(value);
|
||||
}
|
||||
|
||||
if (!clusterNames.empty())
|
||||
clusters[tag] = clusterNames;
|
||||
|
||||
@@ -290,7 +290,7 @@ void
|
||||
MediaScanner::scheduleScan(std::chrono::seconds duration)
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO) << "Scheduling next scan in " << duration.count() << " seconds";
|
||||
_scheduleTimer.expires_from_now(std::chrono::seconds(5)); //duration);
|
||||
_scheduleTimer.expires_from_now(duration);
|
||||
_scheduleTimer.async_wait( std::bind( &MediaScanner::scan, this, std::placeholders::_1) );
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ MediaScanner::scan(boost::system::error_code err)
|
||||
bool forceScan = false;
|
||||
Stats stats;
|
||||
|
||||
checkAudioFiles(stats);
|
||||
removeMissingTracks(stats);
|
||||
|
||||
LMS_LOG(UI, INFO) << "Checks complete, force scan = " << forceScan;
|
||||
|
||||
@@ -325,7 +325,10 @@ MediaScanner::scan(boost::system::error_code err)
|
||||
LMS_LOG(DBUPDATER, INFO) << "scaning media directory '" << _mediaDirectory.string() << "' DONE";
|
||||
|
||||
if (_running)
|
||||
{
|
||||
removeOrphanEntries();
|
||||
checkDuplicatedAudioFiles(stats);
|
||||
}
|
||||
|
||||
LMS_LOG(DBUPDATER, INFO) << "Scan " << (_running ? "complete" : "aborted") << ". Changes = " << stats.nbChanges() << " (added = " << stats.additions << ", removed = " << stats.deletions << ", updated = " << stats.updates << "), Not changed = " << stats.skips << ", Scanned = " << stats.scans << " (errors = " << stats.scanErrors << ", not imported = " << stats.incompleteScans << "), duplicates = " << stats.nbDuplicates() << " (hash = " << stats.duplicateHashes << ", mbid = " << stats.duplicateMBID << ")";
|
||||
|
||||
@@ -655,10 +658,8 @@ checkFile(const boost::filesystem::path& p, boost::filesystem::path mediaDirecto
|
||||
}
|
||||
|
||||
void
|
||||
MediaScanner::checkAudioFiles( Stats& stats )
|
||||
MediaScanner::removeMissingTracks(Stats& stats)
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO) << "Checking audio files...";
|
||||
|
||||
std::vector<boost::filesystem::path> trackPaths = Track::getAllPaths(_db.getSession());;
|
||||
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Checking tracks...";
|
||||
@@ -679,7 +680,11 @@ MediaScanner::checkAudioFiles( Stats& stats )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MediaScanner::removeOrphanEntries()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Checking orphan clusters...";
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
|
||||
@@ -83,7 +83,8 @@ class MediaScanner
|
||||
// Helpers
|
||||
void refreshScanSettings();
|
||||
|
||||
void checkAudioFiles( Stats& stats );
|
||||
void removeMissingTracks( Stats& stats );
|
||||
void removeOrphanEntries();
|
||||
void checkDuplicatedAudioFiles( Stats& stats );
|
||||
void scanAudioFile( const boost::filesystem::path& file, bool forceScan, Stats& stats);
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ DatabaseSettingsView::refreshView()
|
||||
Wt::WPushButton *discardBtn = t->bindWidget("discard-btn", std::make_unique<Wt::WPushButton>(Wt::WString::tr("Lms.discard")));
|
||||
Wt::WPushButton *immScanBtn = t->bindWidget("immediate-scan-btn", std::make_unique<Wt::WPushButton>(Wt::WString::tr("Lms.Admin.Database.immediate-scan")));
|
||||
|
||||
saveBtn->clicked().connect(std::bind([=] ()
|
||||
saveBtn->clicked().connect([=] ()
|
||||
{
|
||||
t->updateModel(model.get());
|
||||
|
||||
@@ -293,20 +293,20 @@ DatabaseSettingsView::refreshView()
|
||||
|
||||
// Udate the view: Delete any validation message in the view, etc.
|
||||
t->updateView(model.get());
|
||||
}));
|
||||
});
|
||||
|
||||
discardBtn->clicked().connect(std::bind([=] ()
|
||||
discardBtn->clicked().connect([=] ()
|
||||
{
|
||||
model->loadData();
|
||||
model->validate();
|
||||
t->updateView(model.get());
|
||||
}));
|
||||
});
|
||||
|
||||
immScanBtn->clicked().connect(std::bind([=] ()
|
||||
immScanBtn->clicked().connect([=] ()
|
||||
{
|
||||
LmsApp->getMediaScanner().scheduleImmediateScan();
|
||||
LmsApp->notifyMsg(MsgType::Info, Wt::WString::tr("Lms.Admin.Database.scan-launched"));
|
||||
}));
|
||||
});
|
||||
|
||||
t->updateView(model.get());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user