diff options
author | Matthew Leeds <matthew.leeds@endlessm.com> | 2019-09-16 14:49:02 -0700 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2019-09-19 15:20:15 +0000 |
commit | 989b18bba8424ef962aec029d11a0e619a9f706c (patch) | |
tree | 954e9fc0097c340b12a3fa95f674c1871263b041 | |
parent | 9c3b42d67e6f67c4716caed49e351a339dc64505 (diff) | |
download | flatpak-989b18bba8424ef962aec029d11a0e619a9f706c.tar.gz |
Set a collection ID on FlatpakInstalledRef objects
Currently FlatpakInstalledRef objects are constructed without the
collection-id property set. This is a problem because in the USB app
update support in the Endless fork of GNOME Software, when we find a
FlatpakRemoteRef on a USB drive which matches the ref of a
FlatpakInstalledRef object, the collection IDs of the two objects must
also match, and currently the installed one has a NULL collection ID.
So get the collection ID on the relevant configured remote when
constructing a FlatpakInstalledRef. This should be good enough in most
cases but isn't perfect; see
https://github.com/flatpak/flatpak/issues/3103
Closes: #3114
Approved by: alexlarsson
-rw-r--r-- | common/flatpak-installation.c | 5 | ||||
-rw-r--r-- | common/flatpak-installed-ref-private.h | 1 | ||||
-rw-r--r-- | common/flatpak-installed-ref.c | 2 | ||||
-rw-r--r-- | tests/testlibrary.c | 4 |
4 files changed, 9 insertions, 3 deletions
diff --git a/common/flatpak-installation.c b/common/flatpak-installation.c index 6e960b68..1fb47b75 100644 --- a/common/flatpak-installation.c +++ b/common/flatpak-installation.c @@ -728,6 +728,7 @@ get_ref (FlatpakDir *dir, g_autofree char *deploy_subdirname = NULL; g_autoptr(GVariant) deploy_data = NULL; g_autofree const char **subpaths = NULL; + g_autofree char *collection_id = NULL; gboolean is_current = FALSE; guint64 installed_size = 0; @@ -757,10 +758,12 @@ get_ref (FlatpakDir *dir, latest_commit = flatpak_dir_read_latest (dir, origin, full_ref, &latest_alt_id, NULL, NULL); + collection_id = flatpak_dir_get_remote_collection_id (dir, origin); + return flatpak_installed_ref_new (full_ref, alt_id ? alt_id : commit, latest_alt_id ? latest_alt_id : latest_commit, - origin, subpaths, + origin, collection_id, subpaths, deploy_path, installed_size, is_current, diff --git a/common/flatpak-installed-ref-private.h b/common/flatpak-installed-ref-private.h index f6d463f8..79f695d3 100644 --- a/common/flatpak-installed-ref-private.h +++ b/common/flatpak-installed-ref-private.h @@ -32,6 +32,7 @@ FlatpakInstalledRef *flatpak_installed_ref_new (const char *full_ref, const char *commit, const char *latest_commit, const char *origin, + const char *collection_id, const char **subpaths, const char *deploy_dir, guint64 installed_size, diff --git a/common/flatpak-installed-ref.c b/common/flatpak-installed-ref.c index 11c08541..c4283839 100644 --- a/common/flatpak-installed-ref.c +++ b/common/flatpak-installed-ref.c @@ -620,6 +620,7 @@ flatpak_installed_ref_new (const char *full_ref, const char *commit, const char *latest_commit, const char *origin, + const char *collection_id, const char **subpaths, const char *deploy_dir, guint64 installed_size, @@ -652,6 +653,7 @@ flatpak_installed_ref_new (const char *full_ref, "commit", commit, "latest-commit", latest_commit, "origin", origin, + "collection-id", collection_id, "subpaths", subpaths, "is-current", is_current, "installed-size", installed_size, diff --git a/tests/testlibrary.c b/tests/testlibrary.c index 4ab2af0b..8e114016 100644 --- a/tests/testlibrary.c +++ b/tests/testlibrary.c @@ -1205,7 +1205,7 @@ test_install_launch_uninstall (void) g_assert_cmpstr (flatpak_ref_get_arch (FLATPAK_REF (ref)), ==, flatpak_get_default_arch ()); g_assert_cmpstr (flatpak_ref_get_branch (FLATPAK_REF (ref)), ==, "master"); g_assert_cmpint (flatpak_ref_get_kind (FLATPAK_REF (ref)), ==, FLATPAK_REF_KIND_RUNTIME); - g_assert_null (flatpak_ref_get_collection_id (FLATPAK_REF (ref))); + g_assert_cmpstr (flatpak_ref_get_collection_id (FLATPAK_REF (ref)), ==, repo_collection_id); g_assert_cmpuint (flatpak_installed_ref_get_installed_size (ref), >, 0); @@ -1253,7 +1253,7 @@ test_install_launch_uninstall (void) g_assert_cmpstr (flatpak_ref_get_arch (FLATPAK_REF (ref)), ==, flatpak_get_default_arch ()); g_assert_cmpstr (flatpak_ref_get_branch (FLATPAK_REF (ref)), ==, "master"); g_assert_cmpint (flatpak_ref_get_kind (FLATPAK_REF (ref)), ==, FLATPAK_REF_KIND_APP); - g_assert_null (flatpak_ref_get_collection_id (FLATPAK_REF (ref))); + g_assert_cmpstr (flatpak_ref_get_collection_id (FLATPAK_REF (ref)), ==, repo_collection_id); g_assert_cmpuint (flatpak_installed_ref_get_installed_size (ref), >, 0); g_assert_true (flatpak_installed_ref_get_is_current (ref)); |