[gnome-software] trivial: Do not allow plugins to change the origin once set



commit f8769cb85cfadf3aeffc6ccbed98f38b8a33228e
Author: Richard Hughes <richard hughsie com>
Date:   Fri Aug 5 21:36:37 2016 +0100

    trivial: Do not allow plugins to change the origin once set

 src/gs-app.c             |   10 ++++++++++
 src/plugins/gs-flatpak.c |    3 ++-
 2 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index a850b63..7721009 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -1624,6 +1624,16 @@ gs_app_set_origin (GsApp *app, const gchar *origin)
        g_return_if_fail (GS_IS_APP (app));
        if (origin == app->origin)
                return;
+
+       /* trying to change */
+       if (app->origin != NULL && origin != NULL) {
+               g_warning ("automatically prevented from changing "
+                          "origin on %s from %s to %s!",
+                          gs_app_get_id (app),
+                          app->origin, origin);
+               return;
+       }
+
        g_free (app->origin);
        app->origin = g_strdup (origin);
 }
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index 94e4824..4b63fe7 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -274,7 +274,8 @@ gs_flatpak_set_metadata_installed (GsFlatpak *self, GsApp *app,
        }
 
        /* this is faster than resolving */
-       gs_app_set_origin (app, flatpak_installed_ref_get_origin (xref));
+       if (gs_app_get_origin (app) == NULL)
+               gs_app_set_origin (app, flatpak_installed_ref_get_origin (xref));
 
        /* this is faster than flatpak_installation_fetch_remote_size_sync() */
        size_installed = flatpak_installed_ref_get_installed_size (xref);


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