diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-02-11 22:50:40 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-02-11 23:01:39 +0100 |
commit | 1facae9ba5deb5af12093d70674b1661b1685c3d (patch) | |
tree | 19d58cdbd5afb6c3ba7a31596fb42759c136f669 | |
parent | 57fe704546267048fe3d4dcc441a9b76c0f4e55a (diff) | |
download | kube-1facae9ba5deb5af12093d70674b1661b1685c3d.tar.gz kube-1facae9ba5deb5af12093d70674b1661b1685c3d.zip |
Restart kube after a storage upgrade.
We currently don't deal with disappearing databases, and the db's are
loaded on process initialization. Thus we have to restart Kube for now
when something was upgraded.
-rw-r--r-- | applications/kube/main.cpp | 17 | ||||
-rw-r--r-- | components/kube/qml/upgrade.qml | 11 |
2 files changed, 20 insertions, 8 deletions
diff --git a/applications/kube/main.cpp b/applications/kube/main.cpp index 2feb8dc9..6cb1f769 100644 --- a/applications/kube/main.cpp +++ b/applications/kube/main.cpp | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <QFont> | 39 | #include <QFont> |
40 | #include <QDebug> | 40 | #include <QDebug> |
41 | #include <QTimer> | 41 | #include <QTimer> |
42 | #include <QQmlContext> | ||
42 | #include <sink/store.h> | 43 | #include <sink/store.h> |
43 | 44 | ||
44 | #include "framework/src/keyring.h" | 45 | #include "framework/src/keyring.h" |
@@ -184,16 +185,20 @@ int main(int argc, char *argv[]) | |||
184 | } | 185 | } |
185 | 186 | ||
186 | { | 187 | { |
188 | QQmlContext *rootContext = nullptr; | ||
187 | bool upgradeComplete = false; | 189 | bool upgradeComplete = false; |
188 | Sink::Store::upgrade().then([&] { | 190 | Sink::Store::upgrade().then([&] (Sink::Store::UpgradeResult upgradeExecuted) { |
189 | upgradeComplete = true; | 191 | upgradeComplete = !upgradeExecuted.upgradeExecuted; |
190 | app.quit(); | 192 | if (rootContext) { |
193 | rootContext->setContextProperty("upgradeComplete", true); | ||
194 | } | ||
191 | }).exec(); | 195 | }).exec(); |
192 | if (!upgradeComplete) { | 196 | if (!upgradeComplete) { |
193 | QQmlApplicationEngine engine; | 197 | QQmlApplicationEngine engine; |
194 | const auto file = findFile("/org/kube/components/kube/upgrade.qml", engine.importPathList()); | 198 | engine.rootContext()->setContextProperty("upgradeComplete", false); |
195 | engine.load(QUrl::fromLocalFile(file)); | 199 | rootContext = engine.rootContext(); |
196 | app.exec(); | 200 | engine.load(QUrl::fromLocalFile(findFile("/org/kube/components/kube/upgrade.qml", engine.importPathList()))); |
201 | return app.exec(); | ||
197 | } | 202 | } |
198 | } | 203 | } |
199 | 204 | ||
diff --git a/components/kube/qml/upgrade.qml b/components/kube/qml/upgrade.qml index 8548b54d..3ce1c63b 100644 --- a/components/kube/qml/upgrade.qml +++ b/components/kube/qml/upgrade.qml | |||
@@ -37,11 +37,18 @@ Controls2.ApplicationWindow { | |||
37 | } | 37 | } |
38 | spacing: 0 | 38 | spacing: 0 |
39 | Kube.Heading { | 39 | Kube.Heading { |
40 | text: qsTr("Please wait while Kube is upgrading...") | 40 | text: !upgradeComplete ? qsTr("Please wait while Kube is upgrading...") : qsTr("Kube has upgraded the storage layer.") |
41 | color: Kube.Colors.highlightColor | 41 | color: Kube.Colors.highlightColor |
42 | } | 42 | } |
43 | Kube.Label { | 43 | Kube.Label { |
44 | text: qsTr("This might take a while.") | 44 | text: !upgradeComplete ? qsTr("This might take a while.") : qsTr("Please exit and restart Kube.") |
45 | } | ||
46 | Kube.Button { | ||
47 | anchors.topMargin: Kube.Units.largeSpacing | ||
48 | text: qsTr("Exit") | ||
49 | onClicked: { | ||
50 | app.close() | ||
51 | } | ||
45 | } | 52 | } |
46 | } | 53 | } |
47 | } | 54 | } |