summaryrefslogtreecommitdiff
path: root/common/flatpak-installation.c
diff options
context:
space:
mode:
authorUmang Jain <mailumangjain@gmail.com>2019-11-21 12:18:55 +0530
committerAlexander Larsson <alexander.larsson@gmail.com>2019-11-22 16:08:32 +0100
commit61f9d19eaeea4e92eeac930a9a14fc367053064c (patch)
tree03a9912716f79bc28cc9b2be8cf7c5c98d02bce5 /common/flatpak-installation.c
parentc76dca855071ab8b6878d3b862f447c1d605646b (diff)
downloadflatpak-61f9d19eaeea4e92eeac930a9a14fc367053064c.tar.gz
installation: Return refs as updatable if related extensions are missing
While updating, if the related extension is missing on the installation of an installed ref (could be an app or runtime), FlatpakTransaction tends to "repair" the ref by automatically downloading the related extension again and restoring the overall functionality of the ref. The related extension concerned that are the ones associated with `should-download` to TRUE only. Hence, teach the libflatpak API to do that same, so that clients like gnome-software can mark those refs as updatable, if their related extensions is missing.
Diffstat (limited to 'common/flatpak-installation.c')
-rw-r--r--common/flatpak-installation.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/common/flatpak-installation.c b/common/flatpak-installation.c
index d6935b1d..b3136c8a 100644
--- a/common/flatpak-installation.c
+++ b/common/flatpak-installation.c
@@ -1002,6 +1002,11 @@ _ostree_collection_ref_free0 (OstreeCollectionRef *ref)
* it can have local updates available that has not been deployed. Look
* at commit vs latest_commit on installed apps for this.
*
+ * This also checks if any of #FlatpakInstalledRef has a missing #FlatpakRelatedRef
+ * (which has `should-download` set to %TRUE). If so, it adds the ref to the
+ * returning #GPtrArray to pull in the #FlatpakRelatedRef again via an update
+ * operation in #FlatpakTransaction.
+ *
* Returns: (transfer container) (element-type FlatpakInstalledRef): a GPtrArray of
* #FlatpakInstalledRef instances, or %NULL on error
*/
@@ -1079,6 +1084,7 @@ flatpak_installation_list_installed_refs_for_update (FlatpakInstallation *self,
for (i = 0; i < installed->len; i++)
{
+ g_autoptr(FlatpakRemoteState) state = NULL;
FlatpakInstalledRef *installed_ref = g_ptr_array_index (installed, i);
const char *remote_name = flatpak_installed_ref_get_origin (installed_ref);
g_autofree char *full_ref = flatpak_ref_format_ref (FLATPAK_REF (installed_ref));
@@ -1092,7 +1098,28 @@ flatpak_installation_list_installed_refs_for_update (FlatpakInstallation *self,
/* Note: local_commit may be NULL here */
if (remote_commit != NULL &&
g_strcmp0 (remote_commit, local_commit) != 0)
- g_ptr_array_add (updates, g_object_ref (installed_ref));
+ {
+ g_ptr_array_add (updates, g_object_ref (installed_ref));
+
+ /* Don't check further, as we already added the installed_ref to @updates. */
+ continue;
+ }
+
+ /* Check if all "should-download" related refs for the ref are installed.
+ * If not, add the ref in @updates array so that it can be installed via
+ * FlatpakTransaction's update-op.
+ *
+ * This makes sure that the ref (maybe an app or runtime) remains in usable
+ * state and fixes itself through an update.
+ */
+ state = flatpak_dir_get_remote_state_optional (dir, remote_name, FALSE, cancellable, error);
+ if (state == NULL)
+ continue;
+
+ if (flatpak_dir_check_installed_ref_missing_related_ref (dir, state, full_ref, cancellable))
+ {
+ g_ptr_array_add (updates, g_object_ref (installed_ref));
+ }
}
collection_refs = g_ptr_array_new_with_free_func ((GDestroyNotify) _ostree_collection_ref_free0);