Commit 3cb9e7b8 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

flatpak: Use the sources map to check if a resource is already being used

We are not using the fetching property anymore and we were emitting some
signals unnecessarily.


(cherry picked from commit 32fd68ca)
parent 25e928aa
Pipeline #141531 passed with stage
in 1 minute and 9 seconds
......@@ -1441,6 +1441,17 @@ ResultsStream *FlatpakBackend::search(const AbstractResourcesBackend::Filters &f
return stream;
}
bool FlatpakBackend::isTracked(FlatpakResource *resource) const
{
const auto uid = resource->uniqueId();
for (const auto &source : m_flatpakSources) {
if (source->m_resources.contains(uid)) {
return true;
}
}
return false;
}
QVector<AbstractResource *> FlatpakBackend::resourcesByAppstreamName(const QString &name) const
{
QVector<AbstractResource *> resources;
......
......@@ -82,6 +82,8 @@ public:
return m_installations;
}
bool isTracked(FlatpakResource *resource) const;
private Q_SLOTS:
void onFetchMetadataFinished(FlatpakResource *resource, const QByteArray &metadata);
void onFetchSizeFinished(FlatpakResource *resource, guint64 downloadSize, guint64 installedSize);
......
......@@ -542,8 +542,9 @@ void FlatpakResource::setState(AbstractResource::State state)
if (m_state != state) {
m_state = state;
if (!backend()->isFetching())
if (qobject_cast<FlatpakBackend *>(backend())->isTracked(this)) {
Q_EMIT stateChanged();
}
}
}
......
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