[gnome-software] flatpak: Set the correct origin when installing a flatpakref



commit 1a4c98b4ffa089985806a76a73d741465f3cff83
Author: Joaquim Rocha <jrocha endlessm com>
Date:   Sat Jul 1 01:33:00 2017 +0200

    flatpak: Set the correct origin when installing a flatpakref
    
    When installing a flatpakref, part of the process is to install its
    ref file, and the code was assuming that this installation always
    results in a new remote (named as app_name-origin). However, if there
    is already a remote with the same URI as the one coming from the ref
    file, it will not add the new one in order to avoid redudancy.
    
    Since the GsApp representing the one in the flatpakref was being
    assigned the "app_name-origin" as its origin, it would fail to install
    later because this expected origin may not exist (as explained above).
    
    To fix this, once the ref file is installed, we get the resulting
    remote's name (i.e. a new one or the existing one) and override the
    app's origin with it, which will allow the installation to succeed.

 plugins/flatpak/gs-flatpak.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index af6834f..a33aa06 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -2779,6 +2779,14 @@ gs_flatpak_app_install (GsFlatpak *self,
                        return FALSE;
                }
 
+               /* the installation of the ref file above will not create a new remote for
+                * the app if its URL is already configured as another remote, thus we
+                * need to update the app origin to match that or it may end up with
+                * an nonexistent origin; and we first need to set the origin to NULL to
+                * circumvent the safety check... */
+               gs_app_set_origin (app, NULL);
+               gs_app_set_origin (app, flatpak_remote_ref_get_remote_name (xref2));
+
                /* update search tokens for new remote */
                if (!gs_flatpak_refresh_appstream (self, G_MAXUINT, 0, cancellable, error)) {
                        gs_app_set_state_recover (app);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]