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