mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-29 03:32:42 +00:00
Corrected count consistency problem in Indexer
This commit is contained in:
parent
a74eb597ad
commit
d5ad390a77
@ -106,8 +106,8 @@ static std::string normalizePath(const std::string& path) {
|
|||||||
|
|
||||||
Indexer::Indexer(const std::string& libraryPath, const std::string& dbFilename)
|
Indexer::Indexer(const std::string& libraryPath, const std::string& dbFilename)
|
||||||
: thread(nullptr)
|
: thread(nullptr)
|
||||||
, tracksScanned(0)
|
, incrementalUrisScanned(0)
|
||||||
, totalTracksScanned(0)
|
, totalUrisScanned(0)
|
||||||
, state(StateStopped)
|
, state(StateStopped)
|
||||||
, prefs(Preferences::ForComponent(prefs::components::Settings))
|
, prefs(Preferences::ForComponent(prefs::components::Settings))
|
||||||
, readSemaphore(prefs->GetInt(prefs::keys::MaxTagReadThreads, MAX_THREADS)) {
|
, readSemaphore(prefs->GetInt(prefs::keys::MaxTagReadThreads, MAX_THREADS)) {
|
||||||
@ -227,8 +227,8 @@ void Indexer::Synchronize(const SyncContext& context, boost::asio::io_service* i
|
|||||||
|
|
||||||
this->ProcessAddRemoveQueue();
|
this->ProcessAddRemoveQueue();
|
||||||
|
|
||||||
this->tracksScanned = 0;
|
this->incrementalUrisScanned = 0;
|
||||||
this->totalTracksScanned = 0;
|
this->totalUrisScanned = 0;
|
||||||
|
|
||||||
/* always remove tracks that no longer have a corresponding source */
|
/* always remove tracks that no longer have a corresponding source */
|
||||||
for (int id : this->GetOrphanedSourceIds()) {
|
for (int id : this->GetOrphanedSourceIds()) {
|
||||||
@ -341,9 +341,6 @@ void Indexer::FinalizeSync(const SyncContext& context) {
|
|||||||
this->SyncOptimize();
|
this->SyncOptimize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* notify observers */
|
|
||||||
this->Progress(this->tracksScanned);
|
|
||||||
|
|
||||||
/* run analyzers. */
|
/* run analyzers. */
|
||||||
this->RunAnalyzers();
|
this->RunAnalyzers();
|
||||||
|
|
||||||
@ -427,13 +424,13 @@ void Indexer::ReadMetadataFromFile(
|
|||||||
inline void Indexer::IncrementTracksScanned(size_t delta) {
|
inline void Indexer::IncrementTracksScanned(size_t delta) {
|
||||||
std::unique_lock<std::mutex> lock(IndexerTrack::sharedWriteMutex);
|
std::unique_lock<std::mutex> lock(IndexerTrack::sharedWriteMutex);
|
||||||
|
|
||||||
this->tracksScanned.fetch_add(delta);
|
this->incrementalUrisScanned.fetch_add(delta);
|
||||||
|
this->totalUrisScanned.fetch_add(delta);
|
||||||
|
|
||||||
if (this->tracksScanned > TRANSACTION_INTERVAL) {
|
if (this->incrementalUrisScanned > TRANSACTION_INTERVAL) {
|
||||||
this->trackTransaction->CommitAndRestart();
|
this->trackTransaction->CommitAndRestart();
|
||||||
this->Progress(this->tracksScanned);
|
this->Progress(this->incrementalUrisScanned);
|
||||||
this->totalTracksScanned += this->tracksScanned;
|
this->incrementalUrisScanned = 0;
|
||||||
this->tracksScanned = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,8 +623,10 @@ void Indexer::ThreadLoop() {
|
|||||||
|
|
||||||
this->dbConnection.Close();
|
this->dbConnection.Close();
|
||||||
|
|
||||||
|
this->Progress(this->incrementalUrisScanned);
|
||||||
|
|
||||||
if (!this->Bail()) {
|
if (!this->Bail()) {
|
||||||
this->Finished(this->totalTracksScanned);
|
this->Finished(this->totalUrisScanned);
|
||||||
}
|
}
|
||||||
|
|
||||||
musik::debug::info(TAG, "done!");
|
musik::debug::info(TAG, "done!");
|
||||||
|
@ -159,7 +159,7 @@ namespace musik { namespace core {
|
|||||||
boost::mutex stateMutex;
|
boost::mutex stateMutex;
|
||||||
boost::condition waitCondition;
|
boost::condition waitCondition;
|
||||||
boost::thread *thread;
|
boost::thread *thread;
|
||||||
std::atomic<size_t> tracksScanned, totalTracksScanned;
|
std::atomic<size_t> incrementalUrisScanned, totalUrisScanned;
|
||||||
std::deque<AddRemoveContext> addRemoveQueue;
|
std::deque<AddRemoveContext> addRemoveQueue;
|
||||||
std::deque<SyncContext> syncQueue;
|
std::deque<SyncContext> syncQueue;
|
||||||
TagReaderList tagReaders;
|
TagReaderList tagReaders;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user