[gnome-software/fix-flatpak-offline-install] flatpak: Fix offline installation




commit 913131779e9b4d93e28e6e7d05801e113e7f03c2
Author: Phaedrus Leeds <matthew leeds endlessm com>
Date:   Tue Sep 8 16:00:58 2020 -0700

    flatpak: Fix offline installation
    
    This commit fixes offline installation of .flatpak bundles, and fixes
    offline installation of .flatpakref files that point to a file:// URL.
    Currently such installations would be forever stuck in the "Pending
    installation..." state. The check for a file:// prefix on the
    gs_app_get_origin_hostname() return value is wrong because in case a
    file:// URL is set, "localhost" is returned. See gs_app_func() in
    lib/gs-self-test.c.
    
    One might wonder if this could be implemented by checking if
    gs_app_get_local_file() returns a non-NULL value, but
    gs_app_set_local_file() is called for flatpakref files which are not
    always offline friendly.
    
    This commit comes from
    https://github.com/endlessm/gnome-software/pull/557

 plugins/flatpak/gs-plugin-flatpak.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index 5b7a5492..571f505f 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -763,7 +763,15 @@ static gboolean
 app_has_local_source (GsApp *app)
 {
        const gchar *url = gs_app_get_origin_hostname (app);
-       return url != NULL && g_str_has_prefix (url, "file://");
+
+       if (gs_flatpak_app_get_file_kind (app) == GS_FLATPAK_APP_FILE_KIND_BUNDLE)
+               return TRUE;
+
+       if (gs_flatpak_app_get_file_kind (app) == GS_FLATPAK_APP_FILE_KIND_REF &&
+           g_strcmp0 (url, "localhost") == 0)
+               return TRUE;
+
+       return FALSE;
 }
 
 gboolean


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