mirror of
https://github.com/YACReader/yacreader
synced 2025-05-27 19:00:29 -04:00
Change the type of path passed to DataBaseManagement::updateToCurrentVersion
This commit is contained in:
parent
d4b7c6dd8a
commit
b0d2d05bc9
@ -853,7 +853,7 @@ int DataBaseManagement::compareVersions(const QString &v1, const QString v2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DataBaseManagement::updateToCurrentVersion(const QString &libraryDataPath)
|
||||
bool DataBaseManagement::updateToCurrentVersion(const QString &libraryPath)
|
||||
{
|
||||
bool pre7 = false;
|
||||
bool pre7_1 = false;
|
||||
@ -863,28 +863,28 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &libraryDataPath)
|
||||
bool pre9_13 = false;
|
||||
bool pre9_14 = false;
|
||||
|
||||
QString fullPath = libraryDataPath + "/library.ydb";
|
||||
QString libraryDatabasePath = LibraryPaths::libraryDatabasePath(libraryPath);
|
||||
|
||||
if (compareVersions(DataBaseManagement::checkValidDB(fullPath), "7.0.0") < 0)
|
||||
if (compareVersions(DataBaseManagement::checkValidDB(libraryDatabasePath), "7.0.0") < 0)
|
||||
pre7 = true;
|
||||
if (compareVersions(DataBaseManagement::checkValidDB(fullPath), "7.0.3") < 0)
|
||||
if (compareVersions(DataBaseManagement::checkValidDB(libraryDatabasePath), "7.0.3") < 0)
|
||||
pre7_1 = true;
|
||||
if (compareVersions(DataBaseManagement::checkValidDB(fullPath), "8.0.0") < 0)
|
||||
if (compareVersions(DataBaseManagement::checkValidDB(libraryDatabasePath), "8.0.0") < 0)
|
||||
pre8 = true;
|
||||
if (compareVersions(DataBaseManagement::checkValidDB(fullPath), "9.5.0") < 0)
|
||||
if (compareVersions(DataBaseManagement::checkValidDB(libraryDatabasePath), "9.5.0") < 0)
|
||||
pre9_5 = true;
|
||||
if (compareVersions(DataBaseManagement::checkValidDB(fullPath), "9.8.0") < 0)
|
||||
if (compareVersions(DataBaseManagement::checkValidDB(libraryDatabasePath), "9.8.0") < 0)
|
||||
pre9_8 = true;
|
||||
if (compareVersions(DataBaseManagement::checkValidDB(fullPath), "9.13.0") < 0)
|
||||
if (compareVersions(DataBaseManagement::checkValidDB(libraryDatabasePath), "9.13.0") < 0)
|
||||
pre9_13 = true;
|
||||
if (compareVersions(DataBaseManagement::checkValidDB(fullPath), "9.14.0") < 0)
|
||||
if (compareVersions(DataBaseManagement::checkValidDB(libraryDatabasePath), "9.14.0") < 0)
|
||||
pre9_14 = true;
|
||||
|
||||
QString connectionName = "";
|
||||
bool returnValue = true;
|
||||
|
||||
{
|
||||
QSqlDatabase db = loadDatabaseFromFile(fullPath);
|
||||
QSqlDatabase db = loadDatabaseFromFile(libraryDatabasePath);
|
||||
if (db.isValid() && db.isOpen()) {
|
||||
if (pre7) // TODO: execute only if previous version was < 7.0
|
||||
{
|
||||
@ -968,7 +968,8 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &libraryDataPath)
|
||||
|
||||
QImageReader thumbnail;
|
||||
while (selectQuery.next()) {
|
||||
thumbnail.setFileName(libraryDataPath % "/covers/" % selectQuery.value(1).toString() % ".jpg");
|
||||
auto coverPath = LibraryPaths::coverPath(libraryPath, selectQuery.value(1).toString());
|
||||
thumbnail.setFileName(coverPath);
|
||||
|
||||
float coverSizeRatio = static_cast<float>(thumbnail.size().width()) / thumbnail.size().height();
|
||||
updateCoverInfo.bindValue(":coverSizeRatio", coverSizeRatio);
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
|
||||
static QString checkValidDB(const QString &fullPath); // retorna "" si la DB es inválida ó la versión si es válida.
|
||||
static int compareVersions(const QString &v1, const QString v2); // retorna <0 si v1 < v2, 0 si v1 = v2 y >0 si v1 > v2
|
||||
static bool updateToCurrentVersion(const QString &path);
|
||||
static bool updateToCurrentVersion(const QString &libraryPath);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -831,8 +831,8 @@ void LibraryWindow::loadLibrary(const QString &name)
|
||||
importWidget->setUpgradeLook();
|
||||
showImportingWidget();
|
||||
|
||||
upgradeLibraryFuture = std::async(std::launch::async, [this, name, path] {
|
||||
bool updated = DataBaseManagement::updateToCurrentVersion(path);
|
||||
upgradeLibraryFuture = std::async(std::launch::async, [this, name, path, rootPath] {
|
||||
bool updated = DataBaseManagement::updateToCurrentVersion(rootPath);
|
||||
|
||||
if (!updated)
|
||||
emit errorUpgradingLibrary(path);
|
||||
|
@ -14,9 +14,9 @@ void LibrariesUpdater::updateIfNeeded()
|
||||
libraries.load();
|
||||
|
||||
foreach (QString name, libraries.getNames()) {
|
||||
QString root = libraries.getPath(name);
|
||||
QString libraryDataPath = YACReader::LibraryPaths::libraryDataPath(root);
|
||||
QString databasePath = YACReader::LibraryPaths::libraryDatabasePath(root);
|
||||
QString libraryPath = libraries.getPath(name);
|
||||
QString libraryDataPath = YACReader::LibraryPaths::libraryDataPath(libraryPath);
|
||||
QString databasePath = YACReader::LibraryPaths::libraryDatabasePath(libraryPath);
|
||||
|
||||
QDir d;
|
||||
|
||||
@ -25,7 +25,7 @@ void LibrariesUpdater::updateIfNeeded()
|
||||
int comparation = DataBaseManagement::compareVersions(dbVersion, DB_VERSION);
|
||||
|
||||
if (comparation < 0) {
|
||||
bool updated = DataBaseManagement::updateToCurrentVersion(libraryDataPath);
|
||||
bool updated = DataBaseManagement::updateToCurrentVersion(libraryPath);
|
||||
if (!updated) {
|
||||
// TODO log error
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user