[ostree] core: Write a refs/summary file for archive repositories
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] core: Write a refs/summary file for archive repositories
- Date: Mon, 27 Feb 2012 13:39:10 +0000 (UTC)
commit 810a3dac86c5b6a9e7c7fb52d380701d21dbb8ca
Author: Colin Walters <walters verbum org>
Date: Mon Feb 27 06:20:42 2012 -0500
core: Write a refs/summary file for archive repositories
This will allow us to retrieve all refs over HTTP easily.
src/libostree/ostree-repo.c | 54 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 7f0ecef..0192b7a 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -1455,6 +1455,54 @@ ostree_repo_list_all_refs (OstreeRepo *repo,
return ret;
}
+static gboolean
+write_ref_summary (OstreeRepo *self,
+ GCancellable *cancellable,
+ GError **error)
+{
+ gboolean ret = FALSE;
+ GHashTable *all_refs = NULL;
+ GHashTableIter hash_iter;
+ gpointer key, value;
+ GFile *summary_path = NULL;
+ GOutputStream *out = NULL;
+ gsize bytes_written;
+ char *buf = NULL;
+
+ if (!ostree_repo_list_all_refs (self, &all_refs, cancellable, error))
+ goto out;
+
+ summary_path = g_file_resolve_relative_path (ostree_repo_get_path (self),
+ "refs/summary");
+
+ out = (GOutputStream*) g_file_replace (summary_path, NULL, FALSE, 0, cancellable, error);
+ if (!out)
+ goto out;
+
+ g_hash_table_iter_init (&hash_iter, all_refs);
+ while (g_hash_table_iter_next (&hash_iter, &key, &value))
+ {
+ const char *name = key;
+ const char *sha256 = value;
+
+ g_free (buf);
+ buf = g_strdup_printf ("%s %s\n", sha256, name);
+ if (!g_output_stream_write_all (out, buf, strlen (buf), &bytes_written, cancellable, error))
+ goto out;
+ }
+
+ if (!g_output_stream_close (out, cancellable, error))
+ goto out;
+
+ ret = TRUE;
+ out:
+ g_free (buf);
+ g_clear_object (&summary_path);
+ g_clear_object (&out);
+ g_hash_table_unref (all_refs);
+ return ret;
+}
+
gboolean
ostree_repo_write_ref (OstreeRepo *self,
const char *remote,
@@ -1479,6 +1527,12 @@ ostree_repo_write_ref (OstreeRepo *self,
if (!write_checksum_file (dir, name, rev, error))
goto out;
+ if (priv->mode == OSTREE_REPO_MODE_ARCHIVE)
+ {
+ if (!write_ref_summary (self, NULL, error))
+ goto out;
+ }
+
ret = TRUE;
out:
g_clear_object (&dir);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]