lib: Use a common helper function to compare checksums

So we get a consistent error message; came up in a PR review.

Closes: #1277
Approved by: jlebon
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2017-10-17 05:06:07 +00:00
1 parent 16c31a9b58
commit e744f2ad6f
5 files changed
+39 -24

No files matched your search

+16
View File
@@ -1004,6 +1004,22 @@ ostree_checksum_file_async_finish (GFile *f,
return TRUE;
}
/* Common helper to compare checksums for an object, so we have a consistent
* error message.
*/
gboolean
_ostree_compare_object_checksum (OstreeObjectType objtype,
const char *expected,
const char *actual,
GError **error)
{
if (!g_str_equal (expected, actual))
return glnx_throw (error, "Corrupted %s object; checksum expected='%s' actual='%s'",
ostree_object_type_to_string (objtype),
expected, actual);
return TRUE;
}
/**
* ostree_create_directory_metadata:
* @dir_info: a #GFileInfo containing directory information