Forráskód Böngészése

Updater: update Linux updater code to work with changes in master

master moved much of the responsibility of the updating process
to the updater class.

This also fixes a build failure
Daniel Molkentin 10 éve
szülő
commit
ecf545a0b9

+ 2 - 16
src/gui/application.cpp

@@ -171,15 +171,11 @@ Application::Application(int &argc, char **argv) :
     UpdaterScheduler *updaterScheduler = new UpdaterScheduler(this);
     connect(updaterScheduler, SIGNAL(updaterAnnouncement(QString, QString)),
             _gui, SLOT(slotShowTrayMessage(QString, QString)));
+    connect(updaterScheduler, SIGNAL(requestRestart()),
+            _folderManager.data(), SLOT(slotScheduleAppRestart()));
 
     // Cleanup at Quit.
     connect (this, SIGNAL(aboutToQuit()), SLOT(slotCleanup()));
-
-    // remember the version of the currently running binary. On Linux it might happen that the
-    // package management updates the package while the app is running. This is detected in the
-    // updater slot: If the installed binary on the hd has a different version than the one
-    // running, the running app is restart. That happens in folderman.
-    _runningAppVersion = Utility::versionOfInstalledBinary();
 }
 
 Application::~Application()
@@ -217,16 +213,6 @@ void Application::slotCleanup()
     _gui->deleteLater();
 }
 
-
-    if( Utility::isLinux() ) {
-        // on linux, check if the installed binary is still the same version
-        // as the one that is running. If not, restart if possible.
-        const QByteArray fsVersion = Utility::versionOfInstalledBinary();
-
-        if( !(fsVersion.isEmpty() || _runningAppVersion.isEmpty()) && fsVersion != _runningAppVersion ) {
-            _folderManager->slotScheduleAppRestart();
-        }
-    }
 void Application::slotCheckConnection()
 {
     auto list = AccountManager::instance()->accounts();

+ 0 - 1
src/gui/application.h

@@ -105,7 +105,6 @@ private:
     bool    _logFlush;
     bool    _userTriggeredConnect;
     bool    _debugMode;
-    QByteArray _runningAppVersion;
 
     ClientProxy _proxy;
 

+ 18 - 0
src/gui/updater/ocupdater.cpp

@@ -48,6 +48,7 @@ UpdaterScheduler::UpdaterScheduler(QObject *parent) :
     if (OCUpdater *updater = dynamic_cast<OCUpdater*>(Updater::instance())) {
         connect(updater,  SIGNAL(newUpdateAvailable(QString,QString)),
                 this,     SIGNAL(updaterAnnouncement(QString,QString)) );
+        connect(updater, SIGNAL(requestRestart()), SIGNAL(requestRestart()));
     }
 
     // at startup, do a check in any case.
@@ -421,7 +422,24 @@ void NSISUpdater::slotSetSeenVersion()
 PassiveUpdateNotifier::PassiveUpdateNotifier(const QUrl &url, QObject *parent)
     : OCUpdater(url, parent)
 {
+    // remember the version of the currently running binary. On Linux it might happen that the
+    // package management updates the package while the app is running. This is detected in the
+    // updater slot: If the installed binary on the hd has a different version than the one
+    // running, the running app is restart. That happens in folderman.
+    _runningAppVersion = Utility::versionOfInstalledBinary();
+}
 
+void PassiveUpdateNotifier::backgroundCheckForUpdate()
+{
+    if( Utility::isLinux() ) {
+        // on linux, check if the installed binary is still the same version
+        // as the one that is running. If not, restart if possible.
+        const QByteArray fsVersion = Utility::versionOfInstalledBinary();
+        qDebug() << Q_FUNC_INFO;
+        if( !(fsVersion.isEmpty() || _runningAppVersion.isEmpty()) && fsVersion != _runningAppVersion ) {
+            emit requestRestart();
+        }
+    }
 }
 
 void PassiveUpdateNotifier::versionInfoArrived(const UpdateInfo &info)

+ 4 - 0
src/gui/updater/ocupdater.h

@@ -72,6 +72,7 @@ public:
 
 signals:
     void updaterAnnouncement(const QString& title, const QString& msg);
+    void requestRestart();
 
 private slots:
     void slotTimerFired();
@@ -106,6 +107,7 @@ public:
 signals:
     void downloadStateChanged();
     void newUpdateAvailable(const QString& header, const QString& message);
+    void requestRestart();
 
 public slots:
     void slotStartInstaller();
@@ -166,9 +168,11 @@ class PassiveUpdateNotifier : public OCUpdater {
 public:
     explicit PassiveUpdateNotifier(const QUrl &url, QObject *parent = 0);
     bool handleStartup() Q_DECL_OVERRIDE { return false; }
+    void backgroundCheckForUpdate() Q_DECL_OVERRIDE;
 
 private:
     void versionInfoArrived(const UpdateInfo &info) Q_DECL_OVERRIDE;
+     QByteArray _runningAppVersion;
 };