diff options
author | Colin Walters <walters@verbum.org> | 2014-07-31 18:50:19 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2014-09-03 13:21:52 -0400 |
commit | f8f5da219edd2279322bba916879fd53c2b65350 (patch) | |
tree | 2bb77d53e3568e70a164112f4b63246737fba45a /src/libotutil/ot-checksum-utils.c | |
parent | 3571418557e3a69d5e86dc464499a59df3d38315 (diff) | |
download | ostree-f8f5da219edd2279322bba916879fd53c2b65350.tar.gz |
Add repository "summary" file and metalink support
For Fedora and potentially other distributions which use globally
distributed mirrors, metalink is a popular solution to redirect
clients to a dynamic set of mirrors.
In order to make metalink work though, it needs *one* file which can
be checksummed. (Well, potentially we could explode all refs into the
metalink.xml, but that would be a lot more invasive, and a bit weird
as we'd end up checksumming the checksum file).
This commit adds a new command:
$ ostree summary -u
To regenerate the summary file. Can only be run by one process at a
time.
After that's done, the metalink can be generated based on it, and the
client fetch code will parse and load it.
https://bugzilla.gnome.org/show_bug.cgi?id=729585
Diffstat (limited to 'src/libotutil/ot-checksum-utils.c')
-rw-r--r-- | src/libotutil/ot-checksum-utils.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libotutil/ot-checksum-utils.c b/src/libotutil/ot-checksum-utils.c index 6a45c01b..b7289929 100644 --- a/src/libotutil/ot-checksum-utils.c +++ b/src/libotutil/ot-checksum-utils.c @@ -139,6 +139,32 @@ ot_gio_checksum_stream (GInputStream *in, return ot_gio_splice_get_checksum (NULL, in, out_csum, cancellable, error); } +char * +ot_checksum_file (GFile *file, + GChecksumType checksum_type, + GCancellable *cancellable, + GError **error) +{ + GChecksum *checksum = NULL; + char *ret = NULL; + gs_unref_object GInputStream *in = NULL; + + in = (GInputStream*)g_file_read (file, cancellable, error); + if (!in) + goto out; + + checksum = g_checksum_new (checksum_type); + + if (!ot_gio_splice_update_checksum (NULL, in, checksum, cancellable, error)) + goto out; + + ret = g_strdup (g_checksum_get_string (checksum)); + out: + g_clear_pointer (&checksum, (GDestroyNotify) g_checksum_free); + return ret; + +} + static void checksum_stream_thread (GSimpleAsyncResult *result, GObject *object, |