Indexer Finished() callback should be sending along the total number of

scanned tracks, not the last batch size.
This commit is contained in:
casey langen 2020-01-31 10:37:04 -08:00
parent 10c27d3141
commit d945268515
3 changed files with 7 additions and 4 deletions

View File

@ -107,6 +107,7 @@ static std::string normalizePath(const std::string& path) {
Indexer::Indexer(const std::string& libraryPath, const std::string& dbFilename)
: thread(nullptr)
, tracksScanned(0)
, totalTracksScanned(0)
, state(StateStopped)
, prefs(Preferences::ForComponent(prefs::components::Settings))
, readSemaphore(prefs->GetInt(prefs::keys::MaxTagReadThreads, MAX_THREADS)) {
@ -227,6 +228,7 @@ void Indexer::Synchronize(const SyncContext& context, boost::asio::io_service* i
this->ProcessAddRemoveQueue();
this->tracksScanned = 0;
this->totalTracksScanned = 0;
/* always remove tracks that no longer have a corresponding source */
for (int id : this->GetOrphanedSourceIds()) {
@ -430,6 +432,7 @@ inline void Indexer::IncrementTracksScanned(size_t delta) {
if (this->tracksScanned > TRANSACTION_INTERVAL) {
this->trackTransaction->CommitAndRestart();
this->Progress(this->tracksScanned);
this->totalTracksScanned += this->tracksScanned;
this->tracksScanned = 0;
}
}
@ -624,7 +627,7 @@ void Indexer::ThreadLoop() {
this->dbConnection.Close();
if (!this->Bail()) {
this->Finished(this->tracksScanned);
this->Finished(this->totalTracksScanned);
}
musik::debug::info(TAG, "done!");

View File

@ -159,7 +159,7 @@ namespace musik { namespace core {
boost::mutex stateMutex;
boost::condition waitCondition;
boost::thread *thread;
std::atomic<size_t> tracksScanned;
std::atomic<size_t> tracksScanned, totalTracksScanned;
std::deque<AddRemoveContext> addRemoveQueue;
std::deque<SyncContext> syncQueue;
TagReaderList tagReaders;

View File

@ -48,8 +48,8 @@ static void indexer_progress_callback(mcsdk_svc_indexer in, int updated_count) {
printf("[indexer_progress_callback] %d\n", total_indexer_updated_count);
}
static void indexer_finished_callback(mcsdk_svc_indexer in, int updated_count) {
printf("[indexer_finished_callback] %d\n", total_indexer_updated_count);
static void indexer_finished_callback(mcsdk_svc_indexer in, int total_updated_count) {
printf("[indexer_finished_callback] %d\n", total_updated_count);
}
static void test_indexer(mcsdk_context* context) {