diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index f4aed7ac..e2ce5c69 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -10928,6 +10928,9 @@ flatpak_dir_find_remote_related (FlatpakDir *self, g_autofree char *extension = NULL; g_autofree char *version = g_key_file_get_string (metakey, groups[i], FLATPAK_METADATA_KEY_VERSION, NULL); + g_auto(GStrv) versions = g_key_file_get_string_list (metakey, groups[i], + FLATPAK_METADATA_KEY_VERSIONS, + NULL, NULL); gboolean subdirectories = g_key_file_get_boolean (metakey, groups[i], FLATPAK_METADATA_KEY_SUBDIRECTORIES, NULL); gboolean no_autodownload = g_key_file_get_boolean (metakey, groups[i], @@ -10939,17 +10942,25 @@ flatpak_dir_find_remote_related (FlatpakDir *self, gboolean locale_subset = g_key_file_get_boolean (metakey, groups[i], FLATPAK_METADATA_KEY_LOCALE_SUBSET, NULL); g_autofree char *extension_collection_id = NULL; - const char *branch; + const char *default_branches[] = { NULL, NULL}; + const char **branches; g_autofree char *extension_ref = NULL; g_autofree char *checksum = NULL; + int branch_i; /* Parse actual extension name */ flatpak_parse_extension_with_tag (tagged_extension, &extension, NULL); - if (version) - branch = version; + if (versions) + branches = (const char **)versions; else - branch = parts[3]; + { + if (version) + default_branches[0] = version; + else + default_branches[0] = parts[3]; + branches = default_branches; + } #ifdef FLATPAK_ENABLE_P2P extension_collection_id = g_key_file_get_string (metakey, groups[i], @@ -10970,24 +10981,29 @@ flatpak_dir_find_remote_related (FlatpakDir *self, g_clear_pointer (&extension_collection_id, g_free); extension_collection_id = g_strdup (state->collection_id); - extension_ref = g_build_filename ("runtime", extension, parts[2], branch, NULL); + for (branch_i = 0; branches[branch_i] != NULL; branch_i++) + { + const char *branch = branches[branch_i]; - if (flatpak_remote_state_lookup_ref (state, extension_ref, &checksum, NULL, NULL)) - { - add_related (self, related, extension, extension_collection_id, extension_ref, checksum, - no_autodownload, download_if, autodelete, locale_subset); - } - else if (subdirectories) - { - g_auto(GStrv) refs = flatpak_remote_state_match_subrefs (state, extension_ref); - int j; - for (j = 0; refs[j] != NULL; j++) + extension_ref = g_build_filename ("runtime", extension, parts[2], branch, NULL); + + if (flatpak_remote_state_lookup_ref (state, extension_ref, &checksum, NULL, NULL)) { - g_autofree char *subref_checksum = NULL; + add_related (self, related, extension, extension_collection_id, extension_ref, checksum, + no_autodownload, download_if, autodelete, locale_subset); + } + else if (subdirectories) + { + g_auto(GStrv) refs = flatpak_remote_state_match_subrefs (state, extension_ref); + int j; + for (j = 0; refs[j] != NULL; j++) + { + g_autofree char *subref_checksum = NULL; - if (flatpak_remote_state_lookup_ref (state, refs[j], &subref_checksum, NULL, NULL)) - add_related (self, related, extension, extension_collection_id, refs[j], subref_checksum, - no_autodownload, download_if, autodelete, locale_subset); + if (flatpak_remote_state_lookup_ref (state, refs[j], &subref_checksum, NULL, NULL)) + add_related (self, related, extension, extension_collection_id, refs[j], subref_checksum, + no_autodownload, download_if, autodelete, locale_subset); + } } } } diff --git a/tests/test-extensions.sh b/tests/test-extensions.sh index 00335cd8..2da7ab0c 100755 --- a/tests/test-extensions.sh +++ b/tests/test-extensions.sh @@ -57,6 +57,7 @@ add_extensions () { mkdir -p $DIR/files/foo/none mkdir -p $DIR/files/foo/dir mkdir -p $DIR/files/foo/dir2 + mkdir -p $DIR/files/foo/multiversion cat >> $DIR/metadata <