Commit 4a874a63 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

flatpak: Do not emit about upgradeable packages that were just created


(cherry picked from commit a3d93b54)
parent 3cb9e7b8
Pipeline #141532 passed with stage
in 1 minute and 53 seconds
......@@ -349,8 +349,10 @@ QString refToBundleId(FlatpakRef *ref)
+ flatpak_ref_get_branch(ref);
}
FlatpakResource *FlatpakBackend::getAppForInstalledRef(FlatpakInstallation *installation, FlatpakInstalledRef *ref) const
FlatpakResource *FlatpakBackend::getAppForInstalledRef(FlatpakInstallation *installation, FlatpakInstalledRef *ref, bool *freshResource) const
{
if (freshResource)
*freshResource = false;
const QString origin = QString::fromUtf8(flatpak_installed_ref_get_origin(ref));
auto source = findSource(installation, origin);
if (source) {
......@@ -410,6 +412,9 @@ FlatpakResource *FlatpakBackend::getAppForInstalledRef(FlatpakInstallation *inst
resource->setState(AbstractResource::Installed);
source->addResource(resource);
if (freshResource)
*freshResource = true;
Q_ASSERT(resource->uniqueId() == idForInstalledRef(ref, {}) || resource->uniqueId() == idForInstalledRef(ref, {".desktop"}));
return resource;
}
......@@ -1287,12 +1292,13 @@ ResultsStream *FlatpakBackend::search(const AbstractResourcesBackend::Filters &f
for (auto it = refs.constBegin(), itEnd = refs.constEnd(); it != itEnd; ++it) {
resources.reserve(resources.size() + it->size());
for (auto ref : qAsConst(it.value())) {
auto resource = getAppForInstalledRef(it.key(), ref);
bool fresh;
auto resource = getAppForInstalledRef(it.key(), ref, &fresh);
#if FLATPAK_CHECK_VERSION(1, 1, 2)
resource->setAvailableVersion(QString::fromUtf8(flatpak_installed_ref_get_appdata_version(ref)));
#endif
g_object_unref(ref);
resource->setState(AbstractResource::Upgradeable);
resource->setState(AbstractResource::Upgradeable, !fresh);
updateAppSize(resource);
if (resource->resourceType() == FlatpakResource::Runtime) {
resources.prepend(resource);
......
......@@ -64,7 +64,7 @@ public:
void addSourceFromFlatpakRepo(const QUrl &url, ResultsStream *stream);
void addAppFromFlatpakBundle(const QUrl &url, ResultsStream *stream);
void addAppFromFlatpakRef(const QUrl &url, ResultsStream *stream);
FlatpakResource *getAppForInstalledRef(FlatpakInstallation *flatpakInstallation, FlatpakInstalledRef *ref) const;
FlatpakResource *getAppForInstalledRef(FlatpakInstallation *flatpakInstallation, FlatpakInstalledRef *ref, bool *freshResource = nullptr) const;
FlatpakSourcesBackend *sources() const
{
......
......@@ -537,12 +537,12 @@ void FlatpakResource::setRuntime(const QString &runtime)
setPropertyState(RequiredRuntime, AlreadyKnown);
}
void FlatpakResource::setState(AbstractResource::State state)
void FlatpakResource::setState(AbstractResource::State state, bool shouldEmit)
{
if (m_state != state) {
m_state = state;
if (qobject_cast<FlatpakBackend *>(backend())->isTracked(this)) {
if (shouldEmit && qobject_cast<FlatpakBackend *>(backend())->isTracked(this)) {
Q_EMIT stateChanged();
}
}
......
......@@ -149,7 +149,7 @@ public:
void setPropertyState(PropertyKind kind, PropertyState state);
void setResourceFile(const QUrl &url);
void setRuntime(const QString &runtime);
void setState(State state);
void setState(State state, bool shouldEmit = false);
void setType(ResourceType type);
void setResourceLocation(const QUrl &location)
{
......
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