Merge pull request #66 from QuasarApp/some_fixes
All checks were successful
buildbot/AndroidBuilder_v8Qt6 Build finished.
buildbot/DocsGenerator Build finished.
buildbot/LinuxCMakeBuilderQt6 Build finished.
buildbot/IOSCMakeBuilder Build finished.
buildbot/WindowsCMakeBuilder Build finished.

Qupdate Quasarapp lib
This commit is contained in:
Andrei Yankovich 2023-10-01 14:19:37 +03:00 committed by GitHub
commit 214b24897f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 11 deletions

View File

@ -28,6 +28,16 @@
#define DEFAULT_DB_INIT_FILE_PATH ":/sql/res/BaseDB.sql" // default database file path
#define DEFAULT_UPDATE_INTERVAL 3600000 // This is interval of update database cache by default it is 1 hour
// Database settings keys
#define QH_DB_DRIVER "DBDriver"
#define QH_DB_FILE_PATH "DBFilePath"
#define QH_DB_INIT_FILE "DBInitFile"
#define QH_DB_PASS "DBPass"
#define QH_DB_LOGIN "DBLogin"
#define QH_DB_HOST "DBHost"
#define QH_DB_PORT "DBPort"
#define QH_DB_BACKUP_PATH "DBBackUpPath"
// Transport Protockol settings
#define ROUTE_CACHE_LIMIT 1000 // This is defaut count of routes in the router class obecjt.
#define TRANSPORT_PACKAGES_CACHE 1000 // This is defaut count of processed packages in the router class obecjt.

View File

@ -173,6 +173,32 @@ QString DataBase::dbLocation() const {
return "";
}
QString DataBase::backUp(int version) const {
auto&& params = defaultDbParams();
if (params.value(QH_DB_DRIVER) != "QSQLITE")
return {};
QString&& path = params.value(QH_DB_BACKUP_PATH).toString();
if (path.isEmpty()) {
return {};
}
auto file = path + "/DBv%0_" + QDateTime::currentDateTimeUtc().toString("hh:mm:ss_dd_MM_yyyy") + ".db";
file = file.arg(version);
if (db() && db()->writer() &&
QFile::exists(db()->writer()->databaseLocation())) {
QDir().mkpath(path);
if (!QFile::copy(db()->writer()->databaseLocation(), file)) {
return {};
}
}
return file;
}
ISqlDB *DataBase::db() const {
return _db;
}
@ -254,7 +280,9 @@ bool DataBase::upgradeDataBase() {
return true;
}
void DataBase::onBeforeDBUpgrade(int , int ) const { }
void DataBase::onBeforeDBUpgrade(int currentVerion, int ) const {
backUp(currentVerion);
}
const QString &DataBase::localNodeName() const {
return _localNodeName;
@ -267,8 +295,9 @@ void DataBase::setLocalNodeName(const QString &newLocalNodeName) {
QVariantMap DataBase::defaultDbParams() const {
return {
{"DBDriver", "QSQLITE"},
{"DBFilePath", DEFAULT_DB_PATH + "/" + localNodeName() + "/" + localNodeName() + "_" + DEFAULT_DB_NAME},
{QH_DB_DRIVER, "QSQLITE"},
{QH_DB_FILE_PATH, DEFAULT_DB_PATH + "/" + localNodeName() + "/" + QCoreApplication::applicationName() + "_" + DEFAULT_DB_NAME},
{QH_DB_BACKUP_PATH, DEFAULT_DB_PATH + "/" + localNodeName() + "/BackUp"}
};
}
}

View File

@ -119,6 +119,13 @@ signals:
protected:
/**
* @brief backUp This method make a backup of database.
* @param version This is current version of db.
* @return path to backupped db.
*/
QString backUp(int version) const;
/**
* @brief localNodeName This method return local node name.
* @return local node name
@ -285,6 +292,7 @@ protected:
* @see DataBase::addDBPatch
*/
virtual void onBeforeDBUpgrade(int currentVerion, int tergetVersion) const;
private:
/**
* @brief workWithSubscribe This method work with subscribe commnads.

View File

@ -163,13 +163,14 @@ protected:
*
* Support parameters of database:
*
* - DBDriver - This is sql driver of data base for more information see The Qt Documentations https://doc.qt.io/qt-5/sql-driver.html
* - DBFilePath - This is path to file of data base (sqlite only). This is phusical location of sqlite database.
* - DBInitFile - This is sql file with sql code (structure) with default structure of the database.
* - DBPass - This is password of a remote database.
* - DBLogin - This is login of a remote database.
* - DBHost - This is host address of a remote database.
* - DBPort - port of a remote database.
* - DBDriver - This is sql driver of data base for more information see The Qt Documentations https://doc.qt.io/qt-5/sql-driver.html (or QH_DB_DRIVER)
* - DBFilePath - This is path to file of data base (sqlite only). This is phusical location of sqlite database. Or (QH_DB_FILE_PATH)
* - DBInitFile - This is sql file with sql code (structure) with default structure of the database. Or (QH_DB_INIT_FILE)
* - DBPass - This is password of a remote database. Or (QH_DB_PASS)
* - DBLogin - This is login of a remote database. Or (QH_DB_LOGIN)
* - DBHost - This is host address of a remote database. Or (QH_DB_HOST)
* - DBPort - port of a remote database. or (QH_DB_PORT)
* - DBBackUpPath - path of database backups (sqlite only). Or (QH_DB_BACKUP_PATH)
*/
virtual QVariantMap defaultInitPararm() const;

@ -1 +1 @@
Subproject commit 53a67709ff90b544036cb90edbfe8cb1ded6dc0b
Subproject commit 90a4284c56856f0cbdb1a7af151d575a468c59eb