Skip to content

Commit

Permalink
lib/repo: Update summary code to use newer hashing API
Browse files Browse the repository at this point in the history
And drop the unnecessary wrapper.

Closes: #1287
Approved by: jlebon
  • Loading branch information
cgwalters authored and rh-atomic-bot committed Oct 18, 2017
1 parent de5f781 commit 40a0b9f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 26 deletions.
18 changes: 8 additions & 10 deletions src/libostree/ostree-repo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 0 additions & 11 deletions src/libotutil/ot-checksum-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions src/libotutil/ot-checksum-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 40a0b9f

Please sign in to comment.