Commit 346f7576 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

flatpak: Check if a bundle is already installed before producing it new

It could be the case and it's useful that it's reflected
parent a3749c14
......@@ -631,6 +631,22 @@ void FlatpakBackend::addAppFromFlatpakBundle(const QUrl &url, ResultsStream *str
g_autoptr(GPtrArray) refs = flatpak_installation_list_installed_refs(preferredInstallation(), m_cancellable, &localError);
if (!refs) {
qWarning() << "Failed to get list of installed refs for listing local updates:" << localError->message;
const QString origin = QString::fromUtf8(flatpak_bundle_ref_get_origin(bundleRef));
for (uint i = 0; i < refs->len; i++) {
FlatpakRef *ref = FLATPAK_REF(g_ptr_array_index(refs, i));
FlatpakInstalledRef *iref = FLATPAK_INSTALLED_REF(g_ptr_array_index(refs, i));
if (qstrcmp(flatpak_ref_get_commit(ref), flatpak_ref_get_commit(FLATPAK_REF(bundleRef))) == 0) {
Q_EMIT stream->resourcesFound({getAppForInstalledRef(preferredInstallation(), iref, nullptr)});
FlatpakResource *resource = new FlatpakResource(asComponent, preferredInstallation(), this);
if (!updateAppMetadata(resource, metadataContent)) {
delete resource;
......@@ -652,8 +668,6 @@ void FlatpakBackend::addAppFromFlatpakBundle(const QUrl &url, ResultsStream *str
const QString origin = QString::fromUtf8(flatpak_bundle_ref_get_origin(bundleRef));
resource->setPropertyState(FlatpakResource::DownloadSize, FlatpakResource::AlreadyKnown);
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