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)
|
if (hasCover)
|
||||||
cover = getFromTrack(trackPath);
|
cover = getFromTrack(trackPath);
|
||||||
else
|
|
||||||
|
if (!cover)
|
||||||
cover = getFromDirectory(trackPath.parent_path());
|
cover = getFromDirectory(trackPath.parent_path());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ class Track : public Wt::Dbo::Dbo<Track>
|
|||||||
std::vector<unsigned char> _fileChecksum;
|
std::vector<unsigned char> _fileChecksum;
|
||||||
Wt::WDateTime _fileLastWrite;
|
Wt::WDateTime _fileLastWrite;
|
||||||
Wt::WDateTime _fileAdded;
|
Wt::WDateTime _fileAdded;
|
||||||
bool _hasCover;
|
bool _hasCover = false;
|
||||||
std::string _MBID; // Musicbrainz Identifier
|
std::string _MBID; // Musicbrainz Identifier
|
||||||
std::string _copyright;
|
std::string _copyright;
|
||||||
std::string _copyrightURL;
|
std::string _copyrightURL;
|
||||||
|
|||||||
@@ -205,8 +205,13 @@ TagLibParser::parse(const boost::filesystem::path& p, bool debug)
|
|||||||
else if (_clusterTypeNames.find(tag) != _clusterTypeNames.end())
|
else if (_clusterTypeNames.find(tag) != _clusterTypeNames.end())
|
||||||
{
|
{
|
||||||
std::set<std::string> clusterNames;
|
std::set<std::string> clusterNames;
|
||||||
for (const auto& value : values)
|
for (const auto& valueList : values)
|
||||||
clusterNames.insert(value.to8Bit(true));
|
{
|
||||||
|
auto values = splitString(valueList.to8Bit(), "/,;");
|
||||||
|
|
||||||
|
for (auto value : values)
|
||||||
|
clusterNames.insert(value);
|
||||||
|
}
|
||||||
|
|
||||||
if (!clusterNames.empty())
|
if (!clusterNames.empty())
|
||||||
clusters[tag] = clusterNames;
|
clusters[tag] = clusterNames;
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ void
|
|||||||
MediaScanner::scheduleScan(std::chrono::seconds duration)
|
MediaScanner::scheduleScan(std::chrono::seconds duration)
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, INFO) << "Scheduling next scan in " << duration.count() << " seconds";
|
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) );
|
_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;
|
bool forceScan = false;
|
||||||
Stats stats;
|
Stats stats;
|
||||||
|
|
||||||
checkAudioFiles(stats);
|
removeMissingTracks(stats);
|
||||||
|
|
||||||
LMS_LOG(UI, INFO) << "Checks complete, force scan = " << forceScan;
|
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";
|
LMS_LOG(DBUPDATER, INFO) << "scaning media directory '" << _mediaDirectory.string() << "' DONE";
|
||||||
|
|
||||||
if (_running)
|
if (_running)
|
||||||
|
{
|
||||||
|
removeOrphanEntries();
|
||||||
checkDuplicatedAudioFiles(stats);
|
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 << ")";
|
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
|
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());;
|
std::vector<boost::filesystem::path> trackPaths = Track::getAllPaths(_db.getSession());;
|
||||||
|
|
||||||
LMS_LOG(DBUPDATER, DEBUG) << "Checking tracks...";
|
LMS_LOG(DBUPDATER, DEBUG) << "Checking tracks...";
|
||||||
@@ -679,7 +680,11 @@ MediaScanner::checkAudioFiles( Stats& stats )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MediaScanner::removeOrphanEntries()
|
||||||
|
{
|
||||||
LMS_LOG(DBUPDATER, DEBUG) << "Checking orphan clusters...";
|
LMS_LOG(DBUPDATER, DEBUG) << "Checking orphan clusters...";
|
||||||
{
|
{
|
||||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ class MediaScanner
|
|||||||
// Helpers
|
// Helpers
|
||||||
void refreshScanSettings();
|
void refreshScanSettings();
|
||||||
|
|
||||||
void checkAudioFiles( Stats& stats );
|
void removeMissingTracks( Stats& stats );
|
||||||
|
void removeOrphanEntries();
|
||||||
void checkDuplicatedAudioFiles( Stats& stats );
|
void checkDuplicatedAudioFiles( Stats& stats );
|
||||||
void scanAudioFile( const boost::filesystem::path& file, bool forceScan, 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 *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")));
|
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());
|
t->updateModel(model.get());
|
||||||
|
|
||||||
@@ -293,20 +293,20 @@ DatabaseSettingsView::refreshView()
|
|||||||
|
|
||||||
// Udate the view: Delete any validation message in the view, etc.
|
// Udate the view: Delete any validation message in the view, etc.
|
||||||
t->updateView(model.get());
|
t->updateView(model.get());
|
||||||
}));
|
});
|
||||||
|
|
||||||
discardBtn->clicked().connect(std::bind([=] ()
|
discardBtn->clicked().connect([=] ()
|
||||||
{
|
{
|
||||||
model->loadData();
|
model->loadData();
|
||||||
model->validate();
|
model->validate();
|
||||||
t->updateView(model.get());
|
t->updateView(model.get());
|
||||||
}));
|
});
|
||||||
|
|
||||||
immScanBtn->clicked().connect(std::bind([=] ()
|
immScanBtn->clicked().connect([=] ()
|
||||||
{
|
{
|
||||||
LmsApp->getMediaScanner().scheduleImmediateScan();
|
LmsApp->getMediaScanner().scheduleImmediateScan();
|
||||||
LmsApp->notifyMsg(MsgType::Info, Wt::WString::tr("Lms.Admin.Database.scan-launched"));
|
LmsApp->notifyMsg(MsgType::Info, Wt::WString::tr("Lms.Admin.Database.scan-launched"));
|
||||||
}));
|
});
|
||||||
|
|
||||||
t->updateView(model.get());
|
t->updateView(model.get());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user