[ostree] core: Fix packed file creation
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] core: Fix packed file creation
- Date: Fri, 2 Dec 2011 22:59:59 +0000 (UTC)
commit 3ab69101f7cfb97eac9f0089339e0d2cb813fd0f
Author: Colin Walters <walters verbum org>
Date: Fri Dec 2 17:49:57 2011 -0500
core: Fix packed file creation
We were calculating the wrong checksum, and also mistakenly
not using packed files in archive mode for non-regular files.
src/libostree/ostree-core.c | 21 ++++++++++++++++++++-
src/libostree/ostree-repo.c | 8 +++-----
2 files changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c
index 93db356..1daf291 100644
--- a/src/libostree/ostree-core.c
+++ b/src/libostree/ostree-core.c
@@ -630,6 +630,11 @@ ostree_pack_file_for_input (GOutputStream *output,
}
else if (S_ISLNK (mode))
{
+ if (out_checksum)
+ {
+ ret_checksum = g_checksum_new (G_CHECKSUM_SHA256);
+ g_checksum_update (ret_checksum, (guint8*)target, object_size);
+ }
if (!g_output_stream_write_all (output, target, object_size,
&bytes_written, cancellable, error))
goto out;
@@ -638,6 +643,11 @@ ostree_pack_file_for_input (GOutputStream *output,
{
guint32 device_be = GUINT32_TO_BE (device);
g_assert (object_size == 4);
+ if (out_checksum)
+ {
+ ret_checksum = g_checksum_new (G_CHECKSUM_SHA256);
+ g_checksum_update (ret_checksum, (guint8*)&device_be, 4);
+ }
if (!g_output_stream_write_all (output, &device_be, object_size,
&bytes_written, cancellable, error))
goto out;
@@ -649,6 +659,13 @@ ostree_pack_file_for_input (GOutputStream *output,
else
g_assert_not_reached ();
+ if (ret_checksum)
+ {
+ ostree_checksum_update_stat (ret_checksum, uid, gid, mode);
+ if (xattrs)
+ g_checksum_update (ret_checksum, (guint8*)g_variant_get_data (xattrs), g_variant_get_size (xattrs));
+ }
+
ret = TRUE;
if (out_checksum)
{
@@ -943,9 +960,11 @@ ostree_create_file_from_input (GFile *dest_file,
else if (S_ISCHR (mode) || S_ISBLK (mode))
{
guint32 dev = g_file_info_get_attribute_uint32 (finfo, "unix::rdev");
+ guint32 dev_be;
g_assert (objtype == OSTREE_OBJECT_TYPE_FILE);
+ dev_be = GUINT32_TO_BE (dev);
if (ret_checksum)
- g_checksum_update (ret_checksum, (guint8*)&dev, 4);
+ g_checksum_update (ret_checksum, (guint8*)&dev_be, 4);
if (mknod (dest_path, mode, dev) < 0)
{
ot_util_set_error_from_errno (error, errno);
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 6d90e6f..0e01469 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -986,14 +986,12 @@ ostree_repo_store_file (OstreeRepo *self,
}
else
{
- /* If we're not an archive, we just need to checksum the input,
- then call link() */
if (!ostree_checksum_file (file, OSTREE_OBJECT_TYPE_FILE, &ret_checksum, cancellable, error))
goto out;
- if (!link_object_trusted (self, file, g_checksum_get_string (ret_checksum),
- OSTREE_OBJECT_TYPE_FILE, FALSE, did_exist,
- cancellable, error))
+ if (!ostree_repo_store_object_trusted (self, file, g_checksum_get_string (ret_checksum),
+ OSTREE_OBJECT_TYPE_FILE, FALSE, did_exist,
+ cancellable, error))
goto out;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]