[ostree] libostree: Add API to write metadata as stream
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] libostree: Add API to write metadata as stream
- Date: Wed, 18 Sep 2013 22:46:44 +0000 (UTC)
commit 9b31b526cc4252e91e012769a5fd1ccb7f976413
Author: Colin Walters <walters verbum org>
Date: Wed Sep 18 18:44:57 2013 -0400
libostree: Add API to write metadata as stream
And use it in pull-local. The goal here is to kill users of
ostree_repo_load_variant(), and move a bit more towards hiding the
variants.
doc/ostree-sections.txt | 1 +
src/libostree/ostree-repo-commit.c | 27 +++++++++++++++++++++++++++
src/libostree/ostree-repo.h | 8 ++++++++
src/ostree/ot-builtin-pull-local.c | 28 +++++++++++-----------------
4 files changed, 47 insertions(+), 17 deletions(-)
---
diff --git a/doc/ostree-sections.txt b/doc/ostree-sections.txt
index aaecbb4..428c69f 100644
--- a/doc/ostree-sections.txt
+++ b/doc/ostree-sections.txt
@@ -76,6 +76,7 @@ ostree_repo_write_metadata
ostree_repo_write_metadata_async
ostree_repo_write_metadata_finish
ostree_repo_write_metadata_trusted
+ostree_repo_write_metadata_stream_trusted
ostree_repo_write_content
ostree_repo_write_content_trusted
ostree_repo_write_content_async
diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c
index cba299f..a2bd263 100644
--- a/src/libostree/ostree-repo-commit.c
+++ b/src/libostree/ostree-repo-commit.c
@@ -824,6 +824,33 @@ ostree_repo_write_metadata (OstreeRepo *self,
}
/**
+ * ostree_repo_write_metadata_stream_trusted:
+ * @self: Repo
+ * @objtype: Object type
+ * @checksum: Store object with this ASCII SHA256 checksum
+ * @object_input: Metadata object stream
+ * @length: Length, may be 0 for unknown
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * Store the metadata object @variant; the provided @checksum is
+ * trusted.
+ */
+gboolean
+ostree_repo_write_metadata_stream_trusted (OstreeRepo *self,
+ OstreeObjectType objtype,
+ const char *checksum,
+ GInputStream *object_input,
+ guint64 length,
+ GCancellable *cancellable,
+ GError **error)
+{
+ /* Ignore provided length for now */
+ return write_object (self, objtype, checksum, object_input, 0, NULL,
+ cancellable, error);
+}
+
+/**
* ostree_repo_write_metadata_trusted:
* @self: Repo
* @objtype: Object type
diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h
index 1511b84..d55874f 100644
--- a/src/libostree/ostree-repo.h
+++ b/src/libostree/ostree-repo.h
@@ -169,6 +169,14 @@ gboolean ostree_repo_write_metadata_trusted (OstreeRepo *self,
GCancellable *cancellable,
GError **error);
+gboolean ostree_repo_write_metadata_stream_trusted (OstreeRepo *self,
+ OstreeObjectType objtype,
+ const char *checksum,
+ GInputStream *object_input,
+ guint64 length,
+ GCancellable *cancellable,
+ GError **error);
+
gboolean ostree_repo_write_content_trusted (OstreeRepo *self,
const char *checksum,
GInputStream *object_input,
diff --git a/src/ostree/ot-builtin-pull-local.c b/src/ostree/ot-builtin-pull-local.c
index 1a03746..f051d6a 100644
--- a/src/ostree/ot-builtin-pull-local.c
+++ b/src/ostree/ot-builtin-pull-local.c
@@ -61,32 +61,26 @@ import_one_object (OtLocalCloneData *data,
GError **error)
{
gboolean ret = FALSE;
+ guint64 length;
+ gs_unref_object GInputStream *object = NULL;
+
+ if (!ostree_repo_load_object_stream (data->src_repo, objtype, checksum,
+ &object, &length,
+ cancellable, error))
+ goto out;
if (objtype == OSTREE_OBJECT_TYPE_FILE)
{
- guint64 length;
- gs_unref_object GInputStream *file_object = NULL;
-
- if (!ostree_repo_load_object_stream (data->src_repo, objtype, checksum,
- &file_object, &length,
- cancellable, error))
- goto out;
-
if (!ostree_repo_write_content_trusted (data->dest_repo, checksum,
- file_object, length,
+ object, length,
cancellable, error))
goto out;
}
else
{
- gs_unref_variant GVariant *metadata = NULL;
-
- if (!ostree_repo_load_variant (data->src_repo, objtype, checksum, &metadata,
- error))
- goto out;
-
- if (!ostree_repo_write_metadata_trusted (data->dest_repo, objtype, checksum, metadata,
- cancellable, error))
+ if (!ostree_repo_write_metadata_stream_trusted (data->dest_repo, objtype,
+ checksum, object, length,
+ cancellable, error))
goto out;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]