Commit ecffc981 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Store the new Snap tuple when refreshing after installing

BUG: 389024
parent 6330ac30
......@@ -112,6 +112,7 @@ ResultsStream * SnapBackend::populate(QSnapdListOneRequest* job, AbstractResourc
resources += res;
} else if (res->state() < state) {
res->setState(state);
res->setSnap(snap);
}
m_resources[res->packageName()] = res;
......@@ -147,6 +148,7 @@ ResultsStream* SnapBackend::populate(T* job, AbstractResource::State state)
resources += res;
} else if (res->state() < state) {
res->setState(state);
res->setSnap(snap);
}
ret += res;
}
......
......@@ -163,3 +163,15 @@ QUrl SnapResource::url() const
//FIXME interim, until it has an appstreamId
return QUrl(QStringLiteral("snap://") + packageName());
}
void SnapResource::setSnap(const QSharedPointer<QSnapdSnap>& snap)
{
Q_ASSERT(snap->name() == m_snap->name());
if (m_snap == snap)
return;
const bool newSize = m_snap->installedSize() != snap->installedSize() || m_snap->downloadSize() != snap->downloadSize();
m_snap = snap;
if (newSize)
Q_EMIT sizeChanged();
}
......@@ -56,6 +56,7 @@ public:
void fetchScreenshots() override;
QList<PackageState> addonsInformation() override { return {}; }
QUrl url() const override;
void setSnap(const QSharedPointer<QSnapdSnap> &snap);
void setState(AbstractResource::State state);
......
......@@ -51,9 +51,9 @@ void SnapTransaction::cancel()
void SnapTransaction::finishTransaction()
{
qDebug() << "done!";
switch(m_request->error()) {
case QSnapdRequest::NoError:
static_cast<SnapBackend*>(m_app->backend())->refreshStates();
m_app->setState(m_newState);
break;
case QSnapdRequest::AuthDataRequired: {
......
Markdown is supported
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