Extract library paths methods to it's own struct in yacreader_global.h and use it everywhere

This commit is contained in:
Luis Ángel San Martín
2025-03-29 11:31:53 +01:00
parent 5aa637fdbe
commit d4b7c6dd8a
15 changed files with 133 additions and 90 deletions

View File

@ -14,16 +14,18 @@ void LibrariesUpdater::updateIfNeeded()
libraries.load();
foreach (QString name, libraries.getNames()) {
QString path = libraries.getPath(name) + "/.yacreaderlibrary";
QString root = libraries.getPath(name);
QString libraryDataPath = YACReader::LibraryPaths::libraryDataPath(root);
QString databasePath = YACReader::LibraryPaths::libraryDatabasePath(root);
QDir d;
QString dbVersion;
if (d.exists(path) && d.exists(path + "/library.ydb") && (dbVersion = DataBaseManagement::checkValidDB(path + "/library.ydb")) != "") {
if (d.exists(libraryDataPath) && d.exists(databasePath) && (dbVersion = DataBaseManagement::checkValidDB(databasePath)) != "") {
int comparation = DataBaseManagement::compareVersions(dbVersion, DB_VERSION);
if (comparation < 0) {
bool updated = DataBaseManagement::updateToCurrentVersion(path);
bool updated = DataBaseManagement::updateToCurrentVersion(libraryDataPath);
if (!updated) {
// TODO log error
}