From 71a7a072743632bad7a042e371db84796a8ada8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 6 Aug 2023 08:55:55 +0200 Subject: [PATCH] Add DB_VERSION to keep track of DBs versions This will make easy to track compatibility with a certain DB structure across different flavors of YACReader. It will only change when the DB structure changes. --- YACReaderLibrary/library_window.cpp | 2 +- YACReaderLibraryServer/libraries_updater.cpp | 2 +- common/yacreader_global.h | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index f4dccd89..967cd3db 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1420,7 +1420,7 @@ void LibraryWindow::loadLibrary(const QString &name) QString dbVersion; if (d.exists(path) && d.exists(path + "/library.ydb") && (dbVersion = DataBaseManagement::checkValidDB(path + "/library.ydb")) != "") // si existe en disco la biblioteca seleccionada, y es vĂ¡lida.. { - int comparation = DataBaseManagement::compareVersions(dbVersion, VERSION); + int comparation = DataBaseManagement::compareVersions(dbVersion, DB_VERSION); if (comparation < 0) { int ret = QMessageBox::question(this, tr("Update needed"), tr("This library was created with a previous version of YACReaderLibrary. It needs to be updated. Update now?"), QMessageBox::Yes, QMessageBox::No); diff --git a/YACReaderLibraryServer/libraries_updater.cpp b/YACReaderLibraryServer/libraries_updater.cpp index 0ef229f5..91af2a24 100644 --- a/YACReaderLibraryServer/libraries_updater.cpp +++ b/YACReaderLibraryServer/libraries_updater.cpp @@ -20,7 +20,7 @@ void LibrariesUpdater::updateIfNeeded() QString dbVersion; if (d.exists(path) && d.exists(path + "/library.ydb") && (dbVersion = DataBaseManagement::checkValidDB(path + "/library.ydb")) != "") { - int comparation = DataBaseManagement::compareVersions(dbVersion, VERSION); + int comparation = DataBaseManagement::compareVersions(dbVersion, DB_VERSION); if (comparation < 0) { bool updated = DataBaseManagement::updateToCurrentVersion(path); diff --git a/common/yacreader_global.h b/common/yacreader_global.h index 2f3a74f9..1f22a203 100644 --- a/common/yacreader_global.h +++ b/common/yacreader_global.h @@ -8,6 +8,10 @@ #define VERSION "9.13.1" +// Used to check if the database needs to be updated, the version is stored in the database. +// This value is only incremented when the database structure changes. +#define DB_VERSION "9.13.1" + #define IMPORT_COMIC_INFO_XML_METADATA "IMPORT_COMIC_INFO_XML_METADATA" #define COMPARE_MODIFIED_DATE_ON_LIBRARY_UPDATES "COMPARE_MODIFIED_DATE_ON_LIBRARY_UPDATES"