forked from Mirrors/flatpak-builder
lib: Move fetch_metadata_sync from RemoteRef to Remote
We want to make the Ref objects pure data storagetingping/wmclass
parent
7da16de205
commit
e7903a8033
|
@ -216,7 +216,7 @@ main (int argc, char *argv[])
|
||||||
xdg_app_ref_get_commit (XDG_APP_REF(remote_ref)),
|
xdg_app_ref_get_commit (XDG_APP_REF(remote_ref)),
|
||||||
xdg_app_remote_ref_get_remote_name (remote_ref));
|
xdg_app_remote_ref_get_remote_name (remote_ref));
|
||||||
|
|
||||||
metadata = xdg_app_remote_ref_fetch_metadata_sync (remote_ref, NULL, &error);
|
metadata = xdg_app_remote_fetch_metadata_sync (remotes[i], xdg_app_ref_get_commit (XDG_APP_REF(remote_ref)), NULL, &error);
|
||||||
if (metadata)
|
if (metadata)
|
||||||
{
|
{
|
||||||
g_print ("metadata: %s\n", (char *)g_bytes_get_data (metadata, NULL));
|
g_print ("metadata: %s\n", (char *)g_bytes_get_data (metadata, NULL));
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
|
|
||||||
XdgAppRemoteRef *xdg_app_remote_ref_new (const char *full_ref,
|
XdgAppRemoteRef *xdg_app_remote_ref_new (const char *full_ref,
|
||||||
const char *commit,
|
const char *commit,
|
||||||
const char *remote_name,
|
const char *remote_name);
|
||||||
XdgAppDir *dir);
|
|
||||||
|
|
||||||
#endif /* __XDG_APP_REMOTE_REF_PRIVATE_H__ */
|
#endif /* __XDG_APP_REMOTE_REF_PRIVATE_H__ */
|
||||||
|
|
|
@ -32,7 +32,6 @@ typedef struct _XdgAppRemoteRefPrivate XdgAppRemoteRefPrivate;
|
||||||
struct _XdgAppRemoteRefPrivate
|
struct _XdgAppRemoteRefPrivate
|
||||||
{
|
{
|
||||||
char *remote_name;
|
char *remote_name;
|
||||||
XdgAppDir *dir;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (XdgAppRemoteRef, xdg_app_remote_ref, XDG_APP_TYPE_REF)
|
G_DEFINE_TYPE_WITH_PRIVATE (XdgAppRemoteRef, xdg_app_remote_ref, XDG_APP_TYPE_REF)
|
||||||
|
@ -50,7 +49,6 @@ xdg_app_remote_ref_finalize (GObject *object)
|
||||||
XdgAppRemoteRefPrivate *priv = xdg_app_remote_ref_get_instance_private (self);
|
XdgAppRemoteRefPrivate *priv = xdg_app_remote_ref_get_instance_private (self);
|
||||||
|
|
||||||
g_free (priv->remote_name);
|
g_free (priv->remote_name);
|
||||||
g_object_unref (priv->dir);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (xdg_app_remote_ref_parent_class)->finalize (object);
|
G_OBJECT_CLASS (xdg_app_remote_ref_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -130,37 +128,14 @@ xdg_app_remote_ref_get_remote_name (XdgAppRemoteRef *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GBytes *
|
|
||||||
xdg_app_remote_ref_fetch_metadata_sync (XdgAppRemoteRef *self,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
XdgAppRemoteRefPrivate *priv = xdg_app_remote_ref_get_instance_private (self);
|
|
||||||
const char *commit;
|
|
||||||
g_autoptr(GBytes) bytes = NULL;
|
|
||||||
|
|
||||||
commit = xdg_app_ref_get_commit (XDG_APP_REF (self));
|
|
||||||
bytes = xdg_app_dir_fetch_metadata (priv->dir,
|
|
||||||
priv->remote_name,
|
|
||||||
commit,
|
|
||||||
cancellable,
|
|
||||||
error);
|
|
||||||
if (bytes == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return g_steal_pointer (&bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
XdgAppRemoteRef *
|
XdgAppRemoteRef *
|
||||||
xdg_app_remote_ref_new (const char *full_ref,
|
xdg_app_remote_ref_new (const char *full_ref,
|
||||||
const char *commit,
|
const char *commit,
|
||||||
const char *remote_name,
|
const char *remote_name)
|
||||||
XdgAppDir *dir)
|
|
||||||
{
|
{
|
||||||
XdgAppRefKind kind = XDG_APP_REF_KIND_APP;
|
XdgAppRefKind kind = XDG_APP_REF_KIND_APP;
|
||||||
g_auto(GStrv) parts = NULL;
|
g_auto(GStrv) parts = NULL;
|
||||||
XdgAppRemoteRef *ref;
|
XdgAppRemoteRef *ref;
|
||||||
XdgAppRemoteRefPrivate *priv;
|
|
||||||
|
|
||||||
parts = g_strsplit (full_ref, "/", -1);
|
parts = g_strsplit (full_ref, "/", -1);
|
||||||
|
|
||||||
|
@ -176,8 +151,5 @@ xdg_app_remote_ref_new (const char *full_ref,
|
||||||
"remote-name", remote_name,
|
"remote-name", remote_name,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
priv = xdg_app_remote_ref_get_instance_private (ref);
|
|
||||||
priv->dir = g_object_ref (dir);
|
|
||||||
|
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,11 +46,6 @@ typedef struct {
|
||||||
|
|
||||||
XDG_APP_EXTERN const char * xdg_app_remote_ref_get_remote_name (XdgAppRemoteRef *self);
|
XDG_APP_EXTERN const char * xdg_app_remote_ref_get_remote_name (XdgAppRemoteRef *self);
|
||||||
|
|
||||||
XDG_APP_EXTERN GBytes *xdg_app_remote_ref_fetch_metadata_sync (XdgAppRemoteRef *self,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GError **error);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
|
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(XdgAppRemoteRef, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(XdgAppRemoteRef, g_object_unref)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -171,6 +171,27 @@ xdg_app_remote_get_gpg_verify (XdgAppRemote *self)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GBytes *
|
||||||
|
xdg_app_remote_fetch_metadata_sync (XdgAppRemote *self,
|
||||||
|
const char *commit,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
XdgAppRemotePrivate *priv = xdg_app_remote_get_instance_private (self);
|
||||||
|
g_autoptr(GBytes) bytes = NULL;
|
||||||
|
|
||||||
|
bytes = xdg_app_dir_fetch_metadata (priv->dir,
|
||||||
|
priv->name,
|
||||||
|
commit,
|
||||||
|
cancellable,
|
||||||
|
error);
|
||||||
|
if (bytes == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return g_steal_pointer (&bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xdg_app_remote_list_refs_sync:
|
* xdg_app_remote_list_refs_sync:
|
||||||
* @self: a #XdgAppRemove
|
* @self: a #XdgAppRemove
|
||||||
|
@ -208,7 +229,7 @@ xdg_app_remote_list_refs_sync (XdgAppRemote *self,
|
||||||
const char *checksum = value;
|
const char *checksum = value;
|
||||||
|
|
||||||
g_ptr_array_add (refs,
|
g_ptr_array_add (refs,
|
||||||
xdg_app_remote_ref_new (refspec, checksum, priv->name, priv->dir));
|
xdg_app_remote_ref_new (refspec, checksum, priv->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_steal_pointer (&refs);
|
return g_steal_pointer (&refs);
|
||||||
|
@ -260,7 +281,7 @@ xdg_app_remote_fetch_ref_sync (XdgAppRemote *self,
|
||||||
checksum = g_hash_table_lookup (ht, ref);
|
checksum = g_hash_table_lookup (ht, ref);
|
||||||
|
|
||||||
if (checksum != NULL)
|
if (checksum != NULL)
|
||||||
return xdg_app_remote_ref_new (ref, checksum, priv->name, priv->dir);
|
return xdg_app_remote_ref_new (ref, checksum, priv->name);
|
||||||
|
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
||||||
"Reference %s doesn't exist in remote\n", ref);
|
"Reference %s doesn't exist in remote\n", ref);
|
||||||
|
|
|
@ -54,6 +54,11 @@ XDG_APP_EXTERN char * xdg_app_remote_get_title (XdgAppRemote *self);
|
||||||
XDG_APP_EXTERN gboolean xdg_app_remote_get_gpg_verify (XdgAppRemote *self);
|
XDG_APP_EXTERN gboolean xdg_app_remote_get_gpg_verify (XdgAppRemote *self);
|
||||||
XDG_APP_EXTERN gboolean xdg_app_remote_get_noenumerate (XdgAppRemote *self);
|
XDG_APP_EXTERN gboolean xdg_app_remote_get_noenumerate (XdgAppRemote *self);
|
||||||
|
|
||||||
|
XDG_APP_EXTERN GBytes *xdg_app_remote_fetch_metadata_sync (XdgAppRemote *self,
|
||||||
|
const char *commit,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
XDG_APP_EXTERN GPtrArray *xdg_app_remote_list_refs_sync (XdgAppRemote *self,
|
XDG_APP_EXTERN GPtrArray *xdg_app_remote_list_refs_sync (XdgAppRemote *self,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
Loading…
Reference in New Issue