Optimized the differential scan step by using threads to check files

This commit is contained in:
emeric
2025-07-19 17:10:15 +02:00
parent 97866d6143
commit 37c75f8677
7 changed files with 162 additions and 87 deletions
+9 -8
View File
@@ -23,6 +23,7 @@
#include "core/ILogger.hpp"
#include "core/ITraceLogger.hpp"
#include "database/objects/Artist.hpp"
#include "database/objects/ArtistInfo.hpp"
#include "database/objects/Artwork.hpp"
@@ -367,17 +368,17 @@ namespace lms::db
});
}
std::size_t Session::getTotalFilesCount()
FileStats Session::getFileStats()
{
std::size_t res{};
FileStats stats{};
res += db::Track::getCount(*this);
res += db::Image::getCount(*this);
res += db::TrackLyrics::getExternalLyricsCount(*this);
res += db::PlayListFile::getCount(*this);
res += db::ArtistInfo::getCount(*this);
stats.trackCount = db::Track::getCount(*this);
stats.artistInfoCount = db::ArtistInfo::getCount(*this);
stats.imageCount = db::Image::getCount(*this);
stats.trackLyricsCount = db::TrackLyrics::getExternalLyricsCount(*this);
stats.playListCount = db::PlayListFile::getCount(*this);
return res;
return stats;
}
void Session::retrieveEntriesToAnalyze(std::vector<std::string>& entryList)
@@ -27,6 +27,7 @@
#include <vector>
#include "database/Transaction.hpp"
#include "database/Types.hpp"
namespace lms::db
{
@@ -52,8 +53,8 @@ namespace lms::db
void retrieveEntriesToAnalyze(std::vector<std::string>& entryList);
void analyzeEntry(const std::string& entry);
bool areAllTablesEmpty(); // need to acquire a read transaction
std::size_t getTotalFilesCount(); // need to acquire a read transaction
bool areAllTablesEmpty(); // need to acquire a read transaction
FileStats getFileStats(); // need to acquire a read transaction
void prepareTablesIfNeeded(); // need to run only once at startup
bool migrateSchemaIfNeeded(); // returns true if migration was performed
@@ -102,6 +102,17 @@ namespace lms::db
}
};
struct FileStats
{
std::size_t trackCount;
std::size_t imageCount;
std::size_t trackLyricsCount;
std::size_t playListCount;
std::size_t artistInfoCount;
std::size_t getTotalFileCount() const { return trackCount + imageCount + trackLyricsCount + playListCount + artistInfoCount; }
};
struct YearRange
{
int begin{};