Commit 33d31c2b authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

rpm-ostree: make the new version checking atomic

No need to parse in one function and process the results elsewhere. This
allows us to maintain the class's state stable.
parent 061b0a0c
...@@ -141,20 +141,9 @@ void RpmOstreeBackend::getDeployments() ...@@ -141,20 +141,9 @@ void RpmOstreeBackend::getDeployments()
void RpmOstreeBackend::toggleFetching() void RpmOstreeBackend::toggleFetching()
{ {
m_fetching = !m_fetching; m_fetching = !m_fetching;
checkForUpdatesNeeded();
emit fetchingChanged(); emit fetchingChanged();
} }
void RpmOstreeBackend::checkForUpdatesNeeded()
{
if (!m_newVersion.isEmpty()) {
m_newVersion.remove(0, 25);
m_newVersion.remove(13, m_newVersion.size() - 13);
m_resources[0]->setNewVersion(m_newVersion);
m_resources[0]->setState(AbstractResource::Upgradeable);
}
}
void RpmOstreeBackend::executeCheckUpdateProcess() void RpmOstreeBackend::executeCheckUpdateProcess()
{ {
QProcess *process = new QProcess(this); QProcess *process = new QProcess(this);
...@@ -179,12 +168,21 @@ void RpmOstreeBackend::executeCheckUpdateProcess() ...@@ -179,12 +168,21 @@ void RpmOstreeBackend::executeCheckUpdateProcess()
void RpmOstreeBackend::readUpdateOutput(QIODevice *device) void RpmOstreeBackend::readUpdateOutput(QIODevice *device)
{ {
QString newVersionFound;
QTextStream stream(device); QTextStream stream(device);
for (QString line = stream.readLine(); stream.readLineInto(&line);) { for (QString line = stream.readLine(); stream.readLineInto(&line);) {
if (line.contains(QLatin1String("Version"))) { if (line.contains(QLatin1String("Version"))) {
m_newVersion = line; newVersionFound = line;
} }
} }
if (!newVersionFound.isEmpty()) {
newVersionFound.remove(0, 25);
newVersionFound.remove(13, newVersionFound.size() - 13);
m_resources[0]->setNewVersion(newVersionFound);
m_resources[0]->setState(AbstractResource::Upgradeable);
}
} }
void RpmOstreeBackend::executeRemoteRefsProcess() void RpmOstreeBackend::executeRemoteRefsProcess()
......
...@@ -101,20 +101,12 @@ private: ...@@ -101,20 +101,12 @@ private:
QString m_transactionUpdatePath; QString m_transactionUpdatePath;
bool m_fetching; bool m_fetching;
QString m_newVersion;
/* /*
* Checking if the required update is deployment update or system upgrade * Checking if the required update is deployment update or system upgrade
* by default isDeploymentUpdate is true * by default isDeploymentUpdate is true
*/ */
bool m_isDeploymentUpdate; bool m_isDeploymentUpdate;
/*
* Extracting the new avaliable version of the deployment from the output
* resulting from QProcess update deployment and setting the current running
* deployment resource to AbstractResource::Upgradeable
*/
void checkForUpdatesNeeded();
}; };
#endif #endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment