[gnome-software/mwleeds/fix-deprecated-install: 5/5] flatpak: Don't use GS_APP_STATE_AVAILABLE_LOCAL for flatpakref files




commit 36a34bbcb47a37418f2f9c225fc6e3c1357a5820
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Wed Nov 3 14:10:31 2021 -0700

    flatpak: Don't use GS_APP_STATE_AVAILABLE_LOCAL for flatpakref files
    
    Use GS_APP_STATE_AVAILABLE instead. While the flatpakref file is
    available locally, the app is available in a remote repo pointed to by
    the local file. If you look at the places where the AVAILABLE_LOCAL
    state is checked, they assume it doesn't make sense to check remote data
    if something is locally available, but in the case of a flatpakref, a
    remote will have been created and it does make sense to check it. The
    only place where it is questionable whether GS_APP_STATE_AVAILABLE is
    what we want for these files is in gs_details_page_refresh_all(), where
    the "Software Repository Included" (infobar_details_app_repo) message is
    shown for AVAILABLE_LOCAL apps. However gs_flatpak_file_to_app_ref()
    adds the origin remote from the flatpakref before displaying the details
    page to the user to let them choose whether to install the app, whereas
    the "Software Repository Included" dialog might make the user think the
    repo would be added upon installation, so it is possibly good to avoid
    it.

 plugins/flatpak/gs-flatpak.c        |  2 +-
 plugins/flatpak/gs-plugin-flatpak.c |  2 +-
 plugins/flatpak/gs-self-test.c      | 11 ++++++-----
 3 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index d154d11b1..7594ee108 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -3640,7 +3640,7 @@ gs_flatpak_file_to_app_ref (GsFlatpak *self,
 
        gs_app_add_quirk (app, GS_APP_QUIRK_HAS_SOURCE);
        gs_flatpak_app_set_file_kind (app, GS_FLATPAK_APP_FILE_KIND_REF);
-       gs_app_set_state (app, GS_APP_STATE_AVAILABLE_LOCAL);
+       gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
 
        /* use the data from the flatpakref file as a fallback */
        ref_title = g_key_file_get_string (kf, "Flatpak Ref", "Title", NULL);
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index 2d0e013c6..efd736803 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -1425,7 +1425,7 @@ gs_plugin_flatpak_file_to_app_ref (GsPluginFlatpak  *self,
                } else {
                        /* the new runtime is available from the RuntimeRepo */
                        if (gs_flatpak_app_get_runtime_url (runtime) != NULL)
-                               gs_app_set_state (runtime, GS_APP_STATE_AVAILABLE_LOCAL);
+                               gs_app_set_state (runtime, GS_APP_STATE_AVAILABLE);
                }
        }
 
diff --git a/plugins/flatpak/gs-self-test.c b/plugins/flatpak/gs-self-test.c
index 4cfe781de..b73aa1366 100644
--- a/plugins/flatpak/gs-self-test.c
+++ b/plugins/flatpak/gs-self-test.c
@@ -727,7 +727,7 @@ gs_plugins_flatpak_runtime_repo_func (GsPluginLoader *plugin_loader)
        g_assert_no_error (error);
        g_assert_true (app != NULL);
        g_assert_cmpint (gs_app_get_kind (app), ==, AS_COMPONENT_KIND_DESKTOP_APP);
-       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE_LOCAL);
+       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE);
        g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
        g_assert_true (as_utils_data_id_equal (gs_app_get_unique_id (app),
                        "user/flatpak/*/org.test.Chiron/master"));
@@ -736,7 +736,7 @@ gs_plugins_flatpak_runtime_repo_func (GsPluginLoader *plugin_loader)
        /* get runtime */
        runtime = gs_app_get_runtime (app);
        g_assert_cmpstr (gs_app_get_unique_id (runtime), ==, "user/flatpak/test/org.test.Runtime/master");
-       g_assert_cmpint (gs_app_get_state (runtime), ==, GS_APP_STATE_AVAILABLE_LOCAL);
+       g_assert_cmpint (gs_app_get_state (runtime), ==, GS_APP_STATE_AVAILABLE);
 
        /* check the number of sources */
        g_object_unref (plugin_job);
@@ -890,7 +890,7 @@ gs_plugins_flatpak_runtime_repo_redundant_func (GsPluginLoader *plugin_loader)
        g_assert_no_error (error);
        g_assert_true (app != NULL);
        g_assert_cmpint (gs_app_get_kind (app), ==, AS_COMPONENT_KIND_DESKTOP_APP);
-       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE_LOCAL);
+       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE);
        g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
        g_assert_true (as_utils_data_id_equal (gs_app_get_unique_id (app),
                        "user/flatpak/*/org.test.Chiron/master"));
@@ -1035,7 +1035,7 @@ gs_plugins_flatpak_broken_remote_func (GsPluginLoader *plugin_loader)
        g_assert_no_error (error);
        g_assert_true (app != NULL);
        g_assert_cmpint (gs_app_get_kind (app), ==, AS_COMPONENT_KIND_DESKTOP_APP);
-       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE_LOCAL);
+       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE);
        g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
 #if FLATPAK_CHECK_VERSION(1,1,2)
        g_assert_true (as_utils_data_id_equal (gs_app_get_unique_id (app),
@@ -1191,7 +1191,6 @@ flatpak_bundle_or_ref_helper (GsPluginLoader *plugin_loader,
        g_assert_no_error (error);
        g_assert_true (app != NULL);
        g_assert_cmpint (gs_app_get_kind (app), ==, AS_COMPONENT_KIND_DESKTOP_APP);
-       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE_LOCAL);
        g_assert_cmpstr (gs_app_get_id (app), ==, "org.test.Chiron");
        g_assert_cmpstr (gs_app_get_name (app), ==, "Chiron");
        g_assert_cmpstr (gs_app_get_summary (app), ==, "Single line synopsis");
@@ -1204,6 +1203,7 @@ flatpak_bundle_or_ref_helper (GsPluginLoader *plugin_loader,
                g_assert_true (as_utils_data_id_equal (gs_app_get_unique_id (app),
                                "user/flatpak/flatpak/org.test.Chiron/master"));
                g_assert_true (gs_flatpak_app_get_file_kind (app) == GS_FLATPAK_APP_FILE_KIND_BUNDLE);
+               g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE_LOCAL);
        } else {
 #if FLATPAK_CHECK_VERSION(1,1,2)
                g_assert_true (as_utils_data_id_equal (gs_app_get_unique_id (app),
@@ -1213,6 +1213,7 @@ flatpak_bundle_or_ref_helper (GsPluginLoader *plugin_loader,
                                "user/flatpak/org.test.Chiron-origin/org.test.Chiron/master"));
 #endif
                g_assert_true (gs_flatpak_app_get_file_kind (app) == GS_FLATPAK_APP_FILE_KIND_REF);
+               g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE);
                g_assert_cmpstr (gs_app_get_url (app, AS_URL_KIND_HOMEPAGE), ==, "http://127.0.0.1/";);
                g_assert_cmpstr (gs_app_get_description (app), ==, "Long description.");
        }


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