mirror of
https://github.com/flatpak/flatpak.git
synced 2026-04-28 19:18:03 -04:00
common: Add (and use) xdg_app_summary_lookup_ref helper
This commit is contained in:
@@ -2791,7 +2791,6 @@ xdg_app_dir_find_remote_ref (XdgAppDir *self,
|
||||
g_autoptr(GVariant) summary = NULL;
|
||||
g_autoptr(GVariant) refs = NULL;
|
||||
g_autoptr(GBytes) summary_bytes = NULL;
|
||||
int pos;
|
||||
|
||||
if (!xdg_app_dir_ensure_repo (self, NULL, error))
|
||||
return NULL;
|
||||
@@ -2847,14 +2846,14 @@ xdg_app_dir_find_remote_ref (XdgAppDir *self,
|
||||
summary = g_variant_new_from_bytes (OSTREE_SUMMARY_GVARIANT_FORMAT, summary_bytes, FALSE);
|
||||
refs = g_variant_get_child_value (summary, 0);
|
||||
|
||||
if (app_ref && xdg_app_variant_bsearch_str (refs, app_ref, &pos))
|
||||
if (app_ref && xdg_app_summary_lookup_ref (summary, app_ref, NULL))
|
||||
{
|
||||
if (is_app)
|
||||
*is_app = TRUE;
|
||||
return g_steal_pointer (&app_ref);
|
||||
}
|
||||
|
||||
if (runtime_ref && xdg_app_variant_bsearch_str (refs, runtime_ref, &pos))
|
||||
if (runtime_ref && xdg_app_summary_lookup_ref (summary, runtime_ref, NULL))
|
||||
{
|
||||
if (is_app)
|
||||
*is_app = FALSE;
|
||||
|
||||
@@ -1456,6 +1456,34 @@ xdg_app_variant_bsearch_str (GVariant *array,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xdg_app_summary_lookup_ref (GVariant *summary, const char *ref, char **out_checksum)
|
||||
{
|
||||
g_autoptr(GVariant) refs = g_variant_get_child_value (summary, 0);
|
||||
int pos;
|
||||
g_autoptr(GVariant) refdata = NULL;
|
||||
g_autoptr(GVariant) reftargetdata = NULL;
|
||||
g_autoptr(GVariant) commit_data = NULL;
|
||||
guint64 commit_size;
|
||||
g_autoptr(GVariant) commit_csum_v = NULL;
|
||||
g_autoptr(GBytes) commit_bytes = NULL;
|
||||
|
||||
if (!xdg_app_variant_bsearch_str (refs, ref, &pos))
|
||||
return FALSE;
|
||||
|
||||
refdata = g_variant_get_child_value (refs, pos);
|
||||
reftargetdata = g_variant_get_child_value (refdata, 1);
|
||||
g_variant_get (reftargetdata, "(t@ay@a{sv})", &commit_size, &commit_csum_v, NULL);
|
||||
|
||||
if (!ostree_validate_structureof_csum_v (commit_csum_v, NULL))
|
||||
return FALSE;
|
||||
|
||||
if (out_checksum)
|
||||
*out_checksum = ostree_checksum_from_bytes_v (commit_csum_v);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xdg_app_repo_set_title (OstreeRepo *repo,
|
||||
const char *title,
|
||||
|
||||
@@ -48,6 +48,9 @@ GBytes * xdg_app_read_stream (GInputStream *in,
|
||||
gboolean xdg_app_variant_bsearch_str (GVariant *array,
|
||||
const char *str,
|
||||
int *out_pos);
|
||||
gboolean xdg_app_summary_lookup_ref (GVariant *summary,
|
||||
const char *ref,
|
||||
char **out_checksum);
|
||||
|
||||
gboolean xdg_app_has_name_prefix (const char *string,
|
||||
const char *name);
|
||||
|
||||
Reference in New Issue
Block a user