Added a way to force rescan artist infos
This commit is contained in:
@@ -35,7 +35,7 @@ namespace lms::db
|
||||
{
|
||||
namespace
|
||||
{
|
||||
static constexpr Version LMS_DATABASE_VERSION{ 89 };
|
||||
static constexpr Version LMS_DATABASE_VERSION{ 90 };
|
||||
}
|
||||
|
||||
VersionInfo::VersionInfo()
|
||||
@@ -1196,6 +1196,16 @@ FROM tracklist)");
|
||||
utils::executeCommand(*session.getDboSession(), "UPDATE scan_settings SET audio_scan_version = audio_scan_version + 1");
|
||||
}
|
||||
|
||||
void migrateFromV89(Session& session)
|
||||
{
|
||||
// ArtistInfo need to be force rescanned: introduced a field for this
|
||||
utils::executeCommand(*session.getDboSession(), "ALTER TABLE scan_settings ADD COLUMN artist_info_scan_version INTEGER NOT NULL DEFAULT(0)");
|
||||
utils::executeCommand(*session.getDboSession(), "ALTER TABLE artist_info ADD COLUMN scan_version INTEGER NOT NULL DEFAULT(0)");
|
||||
|
||||
// Just increment the scan version of the settings to make the next scan rescan everything
|
||||
utils::executeCommand(*session.getDboSession(), "UPDATE scan_settings SET artist_info_scan_version = artist_info_scan_version + 1");
|
||||
}
|
||||
|
||||
bool doDbMigration(Session& session)
|
||||
{
|
||||
constexpr std::string_view outdatedMsg{ "Outdated database, please rebuild it (delete the .db file and restart)" };
|
||||
@@ -1261,6 +1271,7 @@ FROM tracklist)");
|
||||
{ 86, migrateFromV86 },
|
||||
{ 87, migrateFromV87 },
|
||||
{ 88, migrateFromV88 },
|
||||
{ 89, migrateFromV89 },
|
||||
};
|
||||
|
||||
bool migrationPerformed{};
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace lms::db
|
||||
static void findWithArtistNameAmbiguity(Session& session, std::optional<Range> range, bool allowArtistMBIDFallback, const std::function<void(const pointer&)>& func);
|
||||
|
||||
// getters
|
||||
std::size_t getScanVersion() const { return _scanVersion; }
|
||||
const std::filesystem::path& getAbsoluteFilePath() const { return _absoluteFilePath; }
|
||||
const Wt::WDateTime& getLastWriteTime() const { return _fileLastWrite; }
|
||||
ObjectPtr<Directory> getDirectory() const;
|
||||
@@ -69,6 +70,7 @@ namespace lms::db
|
||||
bool isMBIDMatched() const { return _MBIDMatched; }
|
||||
|
||||
// setters
|
||||
void setScanVersion(std::size_t version) { _scanVersion = version; }
|
||||
void setAbsoluteFilePath(const std::filesystem::path& filePath);
|
||||
void setLastWriteTime(Wt::WDateTime time) { _fileLastWrite = time; }
|
||||
void setDirectory(ObjectPtr<Directory> directory);
|
||||
@@ -84,6 +86,7 @@ namespace lms::db
|
||||
template<class Action>
|
||||
void persist(Action& a)
|
||||
{
|
||||
Wt::Dbo::field(a, _scanVersion, "scan_version");
|
||||
Wt::Dbo::field(a, _absoluteFilePath, "absolute_file_path");
|
||||
Wt::Dbo::field(a, _fileLastWrite, "file_last_write");
|
||||
|
||||
@@ -104,6 +107,8 @@ namespace lms::db
|
||||
friend class Session;
|
||||
static pointer create(Session& session);
|
||||
|
||||
int _scanVersion{};
|
||||
|
||||
// Set when coming from artist info file
|
||||
std::filesystem::path _absoluteFilePath;
|
||||
std::string _fileStem;
|
||||
|
||||
@@ -64,6 +64,7 @@ namespace lms::db
|
||||
|
||||
// Getters
|
||||
std::size_t getAudioScanVersion() const { return _audioScanVersion; }
|
||||
std::size_t getArtistInfoScanVersion() const { return _artistInfoScanVersion; }
|
||||
Wt::WTime getUpdateStartTime() const { return _startTime; }
|
||||
UpdatePeriod getUpdatePeriod() const { return _updatePeriod; }
|
||||
std::vector<std::string_view> getExtraTagsToScan() const;
|
||||
@@ -90,6 +91,7 @@ namespace lms::db
|
||||
{
|
||||
Wt::Dbo::field(a, _name, "name");
|
||||
Wt::Dbo::field(a, _audioScanVersion, "audio_scan_version");
|
||||
Wt::Dbo::field(a, _artistInfoScanVersion, "artist_info_scan_version");
|
||||
Wt::Dbo::field(a, _startTime, "start_time");
|
||||
Wt::Dbo::field(a, _updatePeriod, "update_period");
|
||||
Wt::Dbo::field(a, _similarityEngineType, "similarity_engine_type");
|
||||
@@ -111,6 +113,7 @@ namespace lms::db
|
||||
|
||||
std::string _name;
|
||||
int _audioScanVersion{};
|
||||
int _artistInfoScanVersion{};
|
||||
Wt::WTime _startTime = Wt::WTime{ 0, 0, 0 };
|
||||
UpdatePeriod _updatePeriod{ UpdatePeriod::Never };
|
||||
SimilarityEngineType _similarityEngineType{ SimilarityEngineType::Clusters };
|
||||
|
||||
@@ -92,6 +92,7 @@ namespace lms::scanner
|
||||
|
||||
settings.emplace();
|
||||
settings->audioScanVersion = scanSettings->getAudioScanVersion();
|
||||
settings->artistInfoScanVersion = scanSettings->getArtistInfoScanVersion();
|
||||
settings->startTime = scanSettings->getUpdateStartTime();
|
||||
settings->updatePeriod = scanSettings->getUpdatePeriod();
|
||||
|
||||
@@ -420,7 +421,8 @@ namespace lms::scanner
|
||||
return;
|
||||
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Scanner settings updated");
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Using audio scan settings version " << newSettings->audioScanVersion);
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Using audio scan version " << newSettings->audioScanVersion);
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Using artist info scan version " << newSettings->artistInfoScanVersion);
|
||||
|
||||
_settings = std::move(*newSettings);
|
||||
if (!_lastScanSettings)
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace lms::scanner
|
||||
struct ScannerSettings
|
||||
{
|
||||
std::size_t audioScanVersion{};
|
||||
std::size_t artistInfoScanVersion{};
|
||||
Wt::WTime startTime;
|
||||
db::ScanSettings::UpdatePeriod updatePeriod{ db::ScanSettings::UpdatePeriod::Never };
|
||||
bool skipDuplicateTrackMBID{};
|
||||
|
||||
@@ -127,6 +127,7 @@ namespace lms::scanner
|
||||
artistInfo.modify()->setAbsoluteFilePath(_file);
|
||||
}
|
||||
|
||||
artistInfo.modify()->setScanVersion(_settings.artistInfoScanVersion);
|
||||
artistInfo.modify()->setName(_parsedArtistInfo->name);
|
||||
artistInfo.modify()->setSortName(_parsedArtistInfo->sortName);
|
||||
artistInfo.modify()->setLastWriteTime(fileInfo->lastWriteTime);
|
||||
@@ -193,7 +194,9 @@ namespace lms::scanner
|
||||
db::Session& dbSession{ _db.getTLSSession() };
|
||||
auto transaction{ dbSession.createReadTransaction() };
|
||||
db::ArtistInfo::pointer artistInfo{ db::ArtistInfo::find(dbSession, file.file) };
|
||||
if (artistInfo && artistInfo->getLastWriteTime() == lastWriteTime)
|
||||
if (artistInfo
|
||||
&& artistInfo->getLastWriteTime() == lastWriteTime
|
||||
&& artistInfo->getScanVersion() == _settings.artistInfoScanVersion)
|
||||
{
|
||||
context.stats.skips++;
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user