mirror of
https://github.com/YACReader/yacreader
synced 2025-05-25 18:00:46 -04:00
Add the ability to update libraries to new versions in the headless server
It checks the libraries on the start up. It will block the app until everyting it is ready. C
This commit is contained in:
parent
a4941553ec
commit
c593e3570d
39
YACReaderLibraryServer/libraries_updater.cpp
Normal file
39
YACReaderLibraryServer/libraries_updater.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#include "libraries_updater.h"
|
||||
|
||||
#include "yacreader_libraries.h"
|
||||
#include "data_base_management.h"
|
||||
|
||||
|
||||
|
||||
LibrariesUpdater::LibrariesUpdater()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LibrariesUpdater::updateIfNeeded()
|
||||
{
|
||||
YACReaderLibraries libraries;
|
||||
|
||||
libraries.load();
|
||||
|
||||
foreach(QString name, libraries.getNames()) {
|
||||
QString path = libraries.getPath(name) + "/.yacreaderlibrary";
|
||||
|
||||
QDir d;
|
||||
|
||||
QString dbVersion;
|
||||
if(d.exists(path) && d.exists(path+"/library.ydb") && (dbVersion = DataBaseManagement::checkValidDB(path+"/library.ydb")) != "")
|
||||
{
|
||||
int comparation = DataBaseManagement::compareVersions(dbVersion,VERSION);
|
||||
|
||||
if(comparation < 0)
|
||||
{
|
||||
bool updated = DataBaseManagement::updateToCurrentVersion(path);
|
||||
if(!updated) {
|
||||
//TODO log error
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
13
YACReaderLibraryServer/libraries_updater.h
Normal file
13
YACReaderLibraryServer/libraries_updater.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef LIBRARIES_UPDATER_H
|
||||
#define LIBRARIES_UPDATER_H
|
||||
|
||||
|
||||
class LibrariesUpdater
|
||||
{
|
||||
public:
|
||||
LibrariesUpdater();
|
||||
|
||||
void updateIfNeeded();
|
||||
};
|
||||
|
||||
#endif // LIBRARIES_UPDATER_H
|
@ -11,6 +11,8 @@
|
||||
#include "yacreader_libraries.h"
|
||||
#include "yacreader_local_server.h"
|
||||
|
||||
#include "libraries_updater.h"
|
||||
|
||||
#include "console_ui_library_creator.h"
|
||||
|
||||
#include <iostream>
|
||||
@ -136,6 +138,10 @@ int main( int argc, char ** argv )
|
||||
}
|
||||
QLOG_INFO() << "YACReaderLibrary starting";
|
||||
|
||||
//Update libraries to now versions
|
||||
LibrariesUpdater updater;
|
||||
updater.updateIfNeeded();
|
||||
|
||||
YACReaderLocalServer * localServer = new YACReaderLocalServer();
|
||||
|
||||
int ret = app.exec();
|
||||
|
Loading…
Reference in New Issue
Block a user