summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-core.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2017-10-16 14:35:17 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2017-10-17 05:06:07 +0000
commite744f2ad6f620c2d0a5d178cb6115625090ab3e4 (patch)
treee1181914e9623b22f2267ab57b175b942d1f4797 /src/libostree/ostree-core.c
parent16c31a9b580c91ca670c3cdd7143e106ec842ea7 (diff)
downloadostree-e744f2ad6f620c2d0a5d178cb6115625090ab3e4.tar.gz
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
Diffstat (limited to 'src/libostree/ostree-core.c')
-rw-r--r--src/libostree/ostree-core.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c
index 542c54bf..50a2e4fa 100644
--- a/src/libostree/ostree-core.c
+++ b/src/libostree/ostree-core.c
@@ -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