lib/repo: Update summary code to use newer hashing API

And drop the unnecessary wrapper.

Closes: #1287
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-10-17 21:13:20 -04:00 committed by Atomic Bot
parent de5f781089
commit 40a0b9fb73
3 changed files with 8 additions and 26 deletions

View File

@ -4746,18 +4746,16 @@ ostree_repo_regenerate_summary (OstreeRepo *self,
if (!glnx_openat_rdonly (self->repo_dir_fd, superblock, TRUE, &superblock_file_fd, error))
return FALSE;
g_autoptr(GInputStream) in_stream = g_unix_input_stream_new (superblock_file_fd, FALSE);
if (!in_stream)
g_autoptr(GBytes) superblock_content = ot_fd_readall_or_mmap (superblock_file_fd, 0, error);
if (!superblock_content)
return FALSE;
g_auto(OtChecksum) hasher = { 0, };
ot_checksum_init (&hasher);
ot_checksum_update_bytes (&hasher, superblock_content);
guint8 digest[OSTREE_SHA256_DIGEST_LEN];
ot_checksum_get_digest (&hasher, digest, sizeof (digest));
g_autofree guchar *csum = NULL;
if (!ot_gio_checksum_stream (in_stream,
&csum,
cancellable,
error))
return FALSE;
g_variant_dict_insert_value (&deltas_builder, delta_names->pdata[i], ot_gvariant_new_bytearray (csum, 32));
g_variant_dict_insert_value (&deltas_builder, delta_names->pdata[i], ot_gvariant_new_bytearray (digest, sizeof (digest)));
}
if (delta_names->len > 0)

View File

@ -252,17 +252,6 @@ ot_gio_splice_get_checksum (GOutputStream *out,
return TRUE;
}
gboolean
ot_gio_checksum_stream (GInputStream *in,
guchar **out_csum,
GCancellable *cancellable,
GError **error)
{
if (!out_csum)
return TRUE;
return ot_gio_splice_get_checksum (NULL, in, out_csum, cancellable, error);
}
char *
ot_checksum_file_at (int dfd,
const char *path,

View File

@ -88,11 +88,6 @@ gboolean ot_gio_splice_update_checksum (GOutputStream *out,
GCancellable *cancellable,
GError **error);
gboolean ot_gio_checksum_stream (GInputStream *in,
guchar **out_csum,
GCancellable *cancellable,
GError **error);
char * ot_checksum_file_at (int dfd,
const char *path,
GChecksumType checksum_type,