Skip to content

Commit

Permalink
Add option to load last-know-good patch list
Browse files Browse the repository at this point in the history
Contributes-To: sailfishos-patches#277
  • Loading branch information
nephros committed May 26, 2023
1 parent 777d43d commit 2b04ab6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
<method name="getLoaded">
<arg name="loaded" type="b" direction="out" />
</method>
<method name="revertToLastGood">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="resolveFailure">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
Expand Down
6 changes: 6 additions & 0 deletions src/bin/patchmanager-daemon/patchmanagerobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,12 @@ bool PatchManagerObject::getLoaded() const
return m_serverThread->isRunning();
}

void PatchManagerObject::revertToLastGood()
{
m_appliedPatches = getLastGoodPatches();
setAppliedPatches(m_appliedPatches);
}

void PatchManagerObject::resolveFailure()
{
qDebug() << Q_FUNC_INFO;
Expand Down
1 change: 1 addition & 0 deletions src/bin/patchmanager-daemon/patchmanagerobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public slots:
bool getFailure() const;
bool getLoaded() const;
void resolveFailure();
void revertToLastGood();
void loadRequest(bool apply);

void lipstickChanged(const QString &state);
Expand Down
6 changes: 6 additions & 0 deletions src/qml/PatchManagerPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ Page {
onClicked: pageStack.push(Qt.resolvedUrl("RestartServicesDialog.qml"))
}

MenuItem {
text: qsTranslate("", "Load Pre-Failure List")
visible: PatchManager.failure
onClicked: menuRemorse.execute( text, function() { PatchManager.call(PatchManager.revertToLastGood()) } )
}

MenuItem {
text: qsTranslate("", "Resolve failure")
visible: PatchManager.failure
Expand Down
7 changes: 7 additions & 0 deletions src/qml/patchmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,13 @@ void PatchManager::onLoadedChanged(bool loaded)
emit loadedChanged(m_loaded);
}

void PatchManager::revertToLastGood()
{
qDebug() << Q_FUNC_INFO;

m_interface->revertToLastGood();
}

void PatchManager::resolveFailure()
{
qDebug() << Q_FUNC_INFO;
Expand Down
1 change: 1 addition & 0 deletions src/qml/patchmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public slots:
void onFailureChanged(bool failed);
void onLoadedChanged(bool loaded);

void revertToLastGood();
void resolveFailure();

signals:
Expand Down

0 comments on commit 2b04ab6

Please sign in to comment.