[ostree/wip/objtype: 1/3] core: INCOMPATIBLE CHANGE: Name repo files with their type (e.g. .dirmeta)



commit b8e8b58585862a5358b5d924ecb2cc921df831c0
Author: Colin Walters <walters verbum org>
Date:   Fri Dec 9 12:40:41 2011 -0500

    core: INCOMPATIBLE CHANGE: Name repo files with their type (e.g. .dirmeta)
    
    This makes inspection easier.  Internally the code gets simpler because
    metadata and files are more unified; there is just one object type.

 src/libostree/ostree-core.c      |  174 +++++++++++++++-----------------------
 src/libostree/ostree-core.h      |   28 +++----
 src/libostree/ostree-repo-file.c |   52 +++++------
 src/libostree/ostree-repo.c      |  140 ++++++++++++++++---------------
 src/libostree/ostree-repo.h      |   19 ++---
 src/libotutil/ot-gio-utils.c     |   20 ++++-
 src/libotutil/ot-gio-utils.h     |    5 +
 src/ostree/ostree-pull.c         |   36 ++------
 src/ostree/ot-builtin-checksum.c |    2 +-
 src/ostree/ot-builtin-fsck.c     |    2 +-
 src/ostree/ot-builtin-init.c     |    3 +-
 src/ostree/ot-builtin-log.c      |    4 +-
 src/ostree/ot-builtin-show.c     |   56 +++++++++++--
 13 files changed, 272 insertions(+), 269 deletions(-)
---
diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c
index a1c98fd..b9e9347 100644
--- a/src/libostree/ostree-core.c
+++ b/src/libostree/ostree-core.c
@@ -42,8 +42,8 @@ ostree_validate_checksum_string (const char *sha256,
 }
 
 GVariant *
-ostree_wrap_metadata_variant (OstreeSerializedVariantType type,
-                              GVariant *metadata)
+ostree_wrap_metadata_variant (OstreeObjectType  type,
+                              GVariant         *metadata)
 {
   return g_variant_new ("(uv)", GUINT32_TO_BE ((guint32)type), metadata);
 }
@@ -180,58 +180,42 @@ ostree_get_xattrs_for_file (GFile      *f,
   return ret;
 }
 
-static gboolean
-checksum_directory (GFileInfo      *f_info,
-                    GVariant       *xattrs,
-                    GChecksum     **out_checksum,
-                    GCancellable   *cancellable,
-                    GError        **error)
+gboolean
+ostree_checksum_file_from_input (GFileInfo        *file_info,
+                                 GVariant         *xattrs,
+                                 GInputStream     *in,
+                                 OstreeObjectType objtype,
+                                 GChecksum       **out_checksum,
+                                 GCancellable     *cancellable,
+                                 GError          **error)
 {
   gboolean ret = FALSE;
+  GChecksum *ret_checksum = NULL;
   GVariant *dirmeta = NULL;
   GVariant *packed = NULL;
-  GChecksum *ret_checksum = NULL;
+  guint8 buf[8192];
+  gsize bytes_read;
+  guint32 mode;
 
-  dirmeta = ostree_create_directory_metadata (f_info, xattrs);
-  packed = ostree_wrap_metadata_variant (OSTREE_SERIALIZED_DIRMETA_VARIANT, dirmeta);
-  ret_checksum = g_checksum_new (G_CHECKSUM_SHA256);
-  g_checksum_update (ret_checksum, g_variant_get_data (packed),
-                     g_variant_get_size (packed));
+  if (OSTREE_OBJECT_TYPE_IS_META (objtype))
+    return ot_gio_checksum_stream (in, out_checksum, cancellable, error);
 
-  ret = TRUE;
-  ot_transfer_out_value(out_checksum, &ret_checksum);
-  ot_clear_checksum (&ret_checksum);
-  ot_clear_gvariant (&dirmeta);
-  ot_clear_gvariant (&packed);
-  ot_clear_gvariant (&xattrs);
-  return ret;
-}
-
-static gboolean
-checksum_nondirectory (GFileInfo        *file_info,
-                       GVariant         *xattrs,
-                       GInputStream     *input,
-                       OstreeObjectType objtype,
-                       GChecksum       **out_checksum,
-                       GCancellable     *cancellable,
-                       GError          **error)
-{
-  gboolean ret = FALSE;
-  GChecksum *content_sha256 = NULL;
-  GChecksum *content_and_meta_sha256 = NULL;
-  ssize_t bytes_read;
-  guint32 unix_mode;
+  ret_checksum = g_checksum_new (G_CHECKSUM_SHA256);
 
-  content_sha256 = g_checksum_new (G_CHECKSUM_SHA256);
+  mode = g_file_info_get_attribute_uint32 (file_info, "unix::mode");
 
-  unix_mode = g_file_info_get_attribute_uint32 (file_info, "unix::mode");
- 
-  if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR)
+  if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY)
     {
-      guint8 buf[8192];
+      dirmeta = ostree_create_directory_metadata (file_info, xattrs);
+      packed = ostree_wrap_metadata_variant (OSTREE_OBJECT_TYPE_DIR_META, dirmeta);
+      g_checksum_update (ret_checksum, g_variant_get_data (packed),
+                         g_variant_get_size (packed));
 
-      while ((bytes_read = g_input_stream_read (input, buf, sizeof (buf), cancellable, error)) > 0)
-        g_checksum_update (content_sha256, buf, bytes_read);
+    }
+  else if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR)
+    {
+      while ((bytes_read = g_input_stream_read (in, buf, sizeof (buf), cancellable, error)) > 0)
+        g_checksum_update (ret_checksum, buf, bytes_read);
       if (bytes_read < 0)
         goto out;
     }
@@ -239,21 +223,19 @@ checksum_nondirectory (GFileInfo        *file_info,
     {
       const char *symlink_target = g_file_info_get_symlink_target (file_info);
 
-      g_assert (objtype == OSTREE_OBJECT_TYPE_FILE);
       g_assert (symlink_target != NULL);
       
-      g_checksum_update (content_sha256, (guint8*)symlink_target, strlen (symlink_target));
+      g_checksum_update (ret_checksum, (guint8*)symlink_target, strlen (symlink_target));
     }
-  else if (S_ISCHR(unix_mode) || S_ISBLK(unix_mode))
+  else if (S_ISCHR(mode) || S_ISBLK(mode))
     {
       guint32 rdev = g_file_info_get_attribute_uint32 (file_info, "unix::rdev");
-      g_assert (objtype == OSTREE_OBJECT_TYPE_FILE);
       rdev = GUINT32_TO_BE (rdev);
-      g_checksum_update (content_sha256, (guint8*)&rdev, 4);
+      g_checksum_update (ret_checksum, (guint8*)&rdev, 4);
     }
-  else if (S_ISFIFO(unix_mode))
+  else if (S_ISFIFO(mode))
     {
-      g_assert (objtype == OSTREE_OBJECT_TYPE_FILE);
+      ;
     }
   else
     {
@@ -263,48 +245,24 @@ checksum_nondirectory (GFileInfo        *file_info,
       goto out;
     }
 
-  content_and_meta_sha256 = g_checksum_copy (content_sha256);
-
-  if (objtype == OSTREE_OBJECT_TYPE_FILE)
-    {
-      ostree_checksum_update_stat (content_and_meta_sha256,
-                                   g_file_info_get_attribute_uint32 (file_info, "unix::uid"),
-                                   g_file_info_get_attribute_uint32 (file_info, "unix::gid"),
-                                   g_file_info_get_attribute_uint32 (file_info, "unix::mode"));
-      /* FIXME - ensure empty xattrs are the same as NULL xattrs */
-      if (xattrs)
-        g_checksum_update (content_and_meta_sha256, (guint8*)g_variant_get_data (xattrs), g_variant_get_size (xattrs));
-    }
+  ostree_checksum_update_stat (ret_checksum,
+                               g_file_info_get_attribute_uint32 (file_info, "unix::uid"),
+                               g_file_info_get_attribute_uint32 (file_info, "unix::gid"),
+                               g_file_info_get_attribute_uint32 (file_info, "unix::mode"));
+  /* FIXME - ensure empty xattrs are the same as NULL xattrs */
+  if (xattrs)
+    g_checksum_update (ret_checksum, (guint8*)g_variant_get_data (xattrs), g_variant_get_size (xattrs));
 
-  ot_transfer_out_value(out_checksum, &content_and_meta_sha256);
   ret = TRUE;
+  ot_transfer_out_value (out_checksum, &ret_checksum);
  out:
-  ot_clear_checksum (&content_sha256);
-  ot_clear_checksum (&content_and_meta_sha256);
+  ot_clear_checksum (&ret_checksum);
+  ot_clear_gvariant (&dirmeta);
+  ot_clear_gvariant (&packed);
   return ret;
 }
 
 gboolean
-ostree_checksum_file_from_input (GFileInfo        *file_info,
-                                 GVariant         *xattrs,
-                                 GInputStream     *in,
-                                 OstreeObjectType objtype,
-                                 GChecksum       **out_checksum,
-                                 GCancellable     *cancellable,
-                                 GError          **error)
-{
-  if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY)
-    {
-      return checksum_directory (file_info, xattrs, out_checksum, cancellable, error);
-    }
-  else
-    {
-      return checksum_nondirectory (file_info, xattrs, in, objtype,
-                                    out_checksum, cancellable, error);
-    }
-}
-
-gboolean
 ostree_checksum_file (GFile            *f,
                       OstreeObjectType objtype,
                       GChecksum       **out_checksum,
@@ -333,7 +291,7 @@ ostree_checksum_file (GFile            *f,
         goto out;
     }
 
-  if (objtype == OSTREE_OBJECT_TYPE_FILE)
+  if (!OSTREE_OBJECT_TYPE_IS_META(objtype))
     {
       xattrs = ostree_get_xattrs_for_file (f, error);
       if (!xattrs)
@@ -487,7 +445,7 @@ ostree_set_xattrs (GFile  *f,
 
 gboolean
 ostree_parse_metadata_file (GFile                       *file,
-                            OstreeSerializedVariantType *out_type,
+                            OstreeObjectType            *out_type,
                             GVariant                   **out_variant,
                             GError                     **error)
 {
@@ -503,7 +461,7 @@ ostree_parse_metadata_file (GFile                       *file,
   g_variant_get (container, "(uv)",
                  &ret_type, &ret_variant);
   ret_type = GUINT32_FROM_BE (ret_type);
-  if (ret_type <= 0 || ret_type > OSTREE_SERIALIZED_VARIANT_LAST)
+  if (!OSTREE_OBJECT_TYPE_IS_META (ret_type))
     {
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                    "Corrupted metadata object '%s'; invalid type %d",
@@ -524,8 +482,7 @@ ostree_parse_metadata_file (GFile                       *file,
 
 char *
 ostree_get_relative_object_path (const char *checksum,
-                                 OstreeObjectType type,
-                                 gboolean         archive)
+                                 OstreeObjectType type)
 {
   GString *path;
   const char *type_string;
@@ -539,14 +496,20 @@ ostree_get_relative_object_path (const char *checksum,
   g_string_append (path, checksum + 2);
   switch (type)
     {
-    case OSTREE_OBJECT_TYPE_FILE:
-      if (archive)
-        type_string = ".archive";
-      else
-        type_string = ".file";
+    case OSTREE_OBJECT_TYPE_RAW_FILE:
+      type_string = ".file";
+      break;
+    case OSTREE_OBJECT_TYPE_ARCHIVED_FILE:
+      type_string = ".archive";
+      break;
+    case OSTREE_OBJECT_TYPE_DIR_TREE:
+      type_string = ".dirtree";
+      break;
+    case OSTREE_OBJECT_TYPE_DIR_META:
+      type_string = ".dirmeta";
       break;
-    case OSTREE_OBJECT_TYPE_META:
-      type_string = ".meta";
+    case OSTREE_OBJECT_TYPE_COMMIT:
+      type_string = ".commit";
       break;
     default:
       g_assert_not_reached ();
@@ -822,7 +785,7 @@ ostree_create_file_from_input (GFile            *dest_file,
                                GFileInfo        *finfo,
                                GVariant         *xattrs,
                                GInputStream     *input,
-                               OstreeObjectType objtype,
+                               OstreeObjectType  objtype,
                                GChecksum       **out_checksum,
                                GCancellable     *cancellable,
                                GError          **error)
@@ -832,6 +795,7 @@ ostree_create_file_from_input (GFile            *dest_file,
   GFileOutputStream *out = NULL;
   guint32 uid, gid, mode;
   GChecksum *ret_checksum = NULL;
+  gboolean is_meta = OSTREE_OBJECT_TYPE_IS_META (objtype);
 
   if (g_cancellable_set_error_if_cancelled (cancellable, error))
     return FALSE;
@@ -875,7 +839,7 @@ ostree_create_file_from_input (GFile            *dest_file,
   else if (S_ISLNK (mode))
     {
       const char *target = g_file_info_get_attribute_byte_string (finfo, "standard::symlink-target");
-      g_assert (objtype == OSTREE_OBJECT_TYPE_FILE);
+      g_assert (!is_meta);
       if (out_checksum)
         ret_checksum = g_checksum_new (G_CHECKSUM_SHA256);
       if (ret_checksum)
@@ -890,7 +854,7 @@ ostree_create_file_from_input (GFile            *dest_file,
     {
       guint32 dev = g_file_info_get_attribute_uint32 (finfo, "unix::rdev");
       guint32 dev_be;
-      g_assert (objtype == OSTREE_OBJECT_TYPE_FILE);
+      g_assert (!is_meta);
       dev_be = GUINT32_TO_BE (dev);
       if (out_checksum)
         ret_checksum = g_checksum_new (G_CHECKSUM_SHA256);
@@ -904,7 +868,7 @@ ostree_create_file_from_input (GFile            *dest_file,
     }
   else if (S_ISFIFO (mode))
     {
-      g_assert (objtype == OSTREE_OBJECT_TYPE_FILE);
+      g_assert (!is_meta);
       if (out_checksum)
         ret_checksum = g_checksum_new (G_CHECKSUM_SHA256);
       if (mkfifo (dest_path, mode) < 0)
@@ -948,12 +912,12 @@ ostree_create_file_from_input (GFile            *dest_file,
 
   if (xattrs != NULL)
     {
-      g_assert (objtype == OSTREE_OBJECT_TYPE_FILE);
+      g_assert (!is_meta);
       if (!ostree_set_xattrs (dest_file, xattrs, cancellable, error))
         goto out;
     }
 
-  if (ret_checksum && objtype == OSTREE_OBJECT_TYPE_FILE)
+  if (ret_checksum && !is_meta)
     {
       ostree_checksum_update_stat (ret_checksum, uid, gid, mode);
       if (xattrs)
@@ -1102,7 +1066,7 @@ ostree_create_temp_regular_file (GFile            *dir,
   GOutputStream *ret_stream = NULL;
 
   if (!ostree_create_temp_file_from_input (dir, prefix, suffix, NULL, NULL, NULL,
-                                           OSTREE_OBJECT_TYPE_FILE, &ret_file,
+                                           OSTREE_OBJECT_TYPE_RAW_FILE, &ret_file,
                                            NULL, cancellable, error))
     goto out;
   
diff --git a/src/libostree/ostree-core.h b/src/libostree/ostree-core.h
index 1f926c4..e18adbb 100644
--- a/src/libostree/ostree-core.h
+++ b/src/libostree/ostree-core.h
@@ -32,17 +32,15 @@ G_BEGIN_DECLS
 #define OSTREE_EMPTY_STRING_SHA256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
 
 typedef enum {
-  OSTREE_OBJECT_TYPE_FILE = 1,
-  OSTREE_OBJECT_TYPE_META = 2,
+  OSTREE_OBJECT_TYPE_RAW_FILE = 1,   /* .raw */
+  OSTREE_OBJECT_TYPE_ARCHIVED_FILE = 2,  /* .archive */
+  OSTREE_OBJECT_TYPE_DIR_TREE = 3,  /* .dirtree */
+  OSTREE_OBJECT_TYPE_DIR_META = 4,  /* .dirmeta */
+  OSTREE_OBJECT_TYPE_COMMIT = 5     /* .commit */
 } OstreeObjectType;
 
-typedef enum {
-  OSTREE_SERIALIZED_TREE_VARIANT = 1,
-  OSTREE_SERIALIZED_COMMIT_VARIANT = 2,
-  OSTREE_SERIALIZED_DIRMETA_VARIANT = 3,
-  OSTREE_SERIALIZED_XATTR_VARIANT = 4
-} OstreeSerializedVariantType;
-#define OSTREE_SERIALIZED_VARIANT_LAST 4
+#define OSTREE_OBJECT_TYPE_IS_META(t) (t >= 3 && t <= 5)
+#define OSTREE_OBJECT_TYPE_LAST OSTREE_OBJECT_TYPE_COMMIT
 
 #define OSTREE_SERIALIZED_VARIANT_FORMAT "(uv)"
 
@@ -92,28 +90,26 @@ gboolean ostree_validate_checksum_string (const char *sha256,
 
 void ostree_checksum_update_stat (GChecksum *checksum, guint32 uid, guint32 gid, guint32 mode);
 
-char *ostree_get_relative_object_path (const char *checksum,
-                                       OstreeObjectType type,
-                                       gboolean         archive);
+char *ostree_get_relative_object_path (const char        *checksum,
+                                       OstreeObjectType   type);
 
 GVariant *ostree_get_xattrs_for_file (GFile       *f,
                                       GError     **error);
 
-GVariant *ostree_wrap_metadata_variant (OstreeSerializedVariantType type,
-                                        GVariant *metadata);
+GVariant *ostree_wrap_metadata_variant (OstreeObjectType type, GVariant *metadata);
 
 gboolean ostree_set_xattrs (GFile *f, GVariant *xattrs,
                             GCancellable *cancellable, GError **error);
 
 gboolean ostree_parse_metadata_file (GFile                       *file,
-                                     OstreeSerializedVariantType *out_type,
+                                     OstreeObjectType            *out_type,
                                      GVariant                   **out_variant,
                                      GError                     **error);
 
 gboolean ostree_checksum_file_from_input (GFileInfo        *file_info,
                                           GVariant         *xattrs,
                                           GInputStream     *in,
-                                          OstreeObjectType objtype,
+                                          OstreeObjectType  objtype,
                                           GChecksum       **out_checksum,
                                           GCancellable     *cancellable,
                                           GError          **error);
diff --git a/src/libostree/ostree-repo-file.c b/src/libostree/ostree-repo-file.c
index ef0446e..7d11c11 100644
--- a/src/libostree/ostree-repo-file.c
+++ b/src/libostree/ostree-repo-file.c
@@ -172,22 +172,22 @@ do_resolve_commit (OstreeRepoFile  *self,
 
   g_assert (self->parent == NULL);
 
-  if (!ostree_repo_load_variant_checked (self->repo, OSTREE_SERIALIZED_COMMIT_VARIANT,
-                                         self->commit, &commit, error))
+  if (!ostree_repo_load_variant (self->repo, OSTREE_OBJECT_TYPE_COMMIT,
+                                 self->commit, &commit, error))
     goto out;
 
-  /* PARSE OSTREE_SERIALIZED_COMMIT_VARIANT */
+  /* PARSE OSTREE_OBJECT_TYPE_COMMIT */
   g_variant_get_child (commit, 6, "&s", &tree_contents_checksum);
   g_variant_get_child (commit, 7, "&s", &tree_meta_checksum);
 
-  if (!ostree_repo_load_variant_checked (self->repo, OSTREE_SERIALIZED_TREE_VARIANT,
-                                         tree_contents_checksum, &root_contents,
-					 error))
+  if (!ostree_repo_load_variant (self->repo, OSTREE_OBJECT_TYPE_DIR_TREE,
+                                 tree_contents_checksum, &root_contents,
+                                 error))
     goto out;
 
-  if (!ostree_repo_load_variant_checked (self->repo, OSTREE_SERIALIZED_DIRMETA_VARIANT,
-                                         tree_meta_checksum, &root_metadata,
-					 error))
+  if (!ostree_repo_load_variant (self->repo, OSTREE_OBJECT_TYPE_DIR_META,
+                                 tree_meta_checksum, &root_metadata,
+                                 error))
     goto out;
   
   self->tree_metadata = root_metadata;
@@ -241,14 +241,14 @@ do_resolve_nonroot (OstreeRepoFile     *self,
       if (!ot_util_filename_validate (name, error))
         goto out;
           
-      if (!ostree_repo_load_variant_checked (self->repo, OSTREE_SERIALIZED_TREE_VARIANT,
-                                             content_checksum, &tree_contents,
-                                             error))
+      if (!ostree_repo_load_variant (self->repo, OSTREE_OBJECT_TYPE_DIR_TREE,
+                                     content_checksum, &tree_contents,
+                                     error))
         goto out;
           
-      if (!ostree_repo_load_variant_checked (self->repo, OSTREE_SERIALIZED_DIRMETA_VARIANT,
-                                             metadata_checksum, &tree_metadata,
-                                             error))
+      if (!ostree_repo_load_variant (self->repo, OSTREE_OBJECT_TYPE_DIR_META,
+                                     metadata_checksum, &tree_metadata,
+                                     error))
         goto out;
 
       self->tree_contents = tree_contents;
@@ -381,7 +381,7 @@ _ostree_repo_file_tree_get_content_checksum (OstreeRepoFile  *self)
 GFile *
 _ostree_repo_file_nontree_get_local (OstreeRepoFile  *self)
 {
-  return ostree_repo_get_object_path (self->repo, _ostree_repo_file_get_checksum (self), OSTREE_OBJECT_TYPE_FILE);
+  return ostree_repo_get_file_object_path (self->repo, _ostree_repo_file_get_checksum (self));
 }
 
 OstreeRepo *
@@ -685,13 +685,6 @@ ostree_repo_file_get_child_for_display_name (GFile        *file,
   return g_file_get_child (file, display_name);
 }
 
-static GFile *
-get_child_local_file (OstreeRepo   *repo,
-                      const char   *checksum)
-{
-  return ostree_repo_get_object_path (repo, checksum, OSTREE_OBJECT_TYPE_FILE);
-}
-
 static void
 set_info_from_dirmeta (GFileInfo  *info,
                        GVariant   *metadata)
@@ -700,7 +693,7 @@ set_info_from_dirmeta (GFileInfo  *info,
 
   g_file_info_set_attribute_uint32 (info, "standard::type", G_FILE_TYPE_DIRECTORY);
 
-  /* PARSE OSTREE_SERIALIZED_DIRMETA_VARIANT */
+  /* PARSE OSTREE_OBJECT_TYPE_DIR_META */
   g_variant_get (metadata, "(uuuu a(ayay))",
                  &version, &uid, &gid, &mode,
                  NULL);
@@ -731,8 +724,8 @@ query_child_info_dir (OstreeRepo               *repo,
 
   if (g_file_attribute_matcher_matches (matcher, "unix::mode"))
     {
-      if (!ostree_repo_load_variant_checked (repo, OSTREE_SERIALIZED_DIRMETA_VARIANT,
-                                             metadata_checksum, &metadata, error))
+      if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_DIR_META,
+                                     metadata_checksum, &metadata, error))
         goto out;
 
       set_info_from_dirmeta (ret_info, metadata);
@@ -1033,7 +1026,7 @@ _ostree_repo_file_tree_query_child (OstreeRepoFile  *self,
 
       g_variant_get_child (files_variant, n, "(&s&s)", &name, &checksum);
 
-      local_child = get_child_local_file (self->repo, checksum);
+      local_child = ostree_repo_get_file_object_path (self->repo, checksum);
 
       if (ostree_repo_get_mode (self->repo) == OSTREE_REPO_MODE_ARCHIVE)
 	{
@@ -1047,6 +1040,8 @@ _ostree_repo_file_tree_query_child (OstreeRepoFile  *self,
                                         G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
                                         cancellable,
                                         error);
+          if (!ret_info)
+            goto out;
 	}
     }
   else
@@ -1068,8 +1063,6 @@ _ostree_repo_file_tree_query_child (OstreeRepoFile  *self,
                                      cancellable, error))
             goto out;
         }
-      else
-        n -= c;
     }
 
   if (name)
@@ -1124,6 +1117,7 @@ ostree_repo_file_query_info (GFile                *file,
                                                attributes, flags, 
                                                &info, cancellable, error))
         goto out;
+      g_assert (info != NULL);
     }
       
   ret = TRUE;
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index f180773..6a8ead8 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -296,7 +296,7 @@ ostree_repo_resolve_rev (OstreeRepo     *self,
       if (!ostree_repo_resolve_rev (self, tmp, allow_noent, &tmp2, error))
         goto out;
 
-      if (!ostree_repo_load_variant_checked (self, OSTREE_SERIALIZED_COMMIT_VARIANT, tmp2, &commit, error))
+      if (!ostree_repo_load_variant (self, OSTREE_OBJECT_TYPE_COMMIT, tmp2, &commit, error))
         goto out;
       
       g_variant_get_child (commit, 2, "s", &ret_rev);
@@ -642,6 +642,23 @@ ostree_repo_get_mode (OstreeRepo  *self)
   return priv->mode;
 }
 
+static OstreeObjectType
+get_objtype_for_repo_file (OstreeRepo *self)
+{
+  OstreeRepoPrivate *priv = GET_PRIVATE (self);
+  if (priv->mode == OSTREE_REPO_MODE_ARCHIVE)
+    return OSTREE_OBJECT_TYPE_ARCHIVED_FILE;
+  else
+    return OSTREE_OBJECT_TYPE_RAW_FILE;
+}
+
+GFile *
+ostree_repo_get_file_object_path (OstreeRepo   *self,
+                                  const char   *checksum)
+{
+  return ostree_repo_get_object_path (self, checksum, get_objtype_for_repo_file (self));
+}
+
 static gboolean
 ostree_repo_stage_object (OstreeRepo         *self,
                           OstreeObjectType    objtype,
@@ -663,7 +680,7 @@ ostree_repo_stage_object (OstreeRepo         *self,
   if (g_cancellable_set_error_if_cancelled (cancellable, error))
     return FALSE;
 
-  if (objtype == OSTREE_OBJECT_TYPE_FILE && priv->mode == OSTREE_REPO_MODE_ARCHIVE)
+  if (!OSTREE_OBJECT_TYPE_IS_META(objtype) && priv->mode == OSTREE_REPO_MODE_ARCHIVE)
     {
       if (!ostree_create_temp_regular_file (priv->tmp_dir,
                                             "archive-tmp-", NULL,
@@ -796,6 +813,7 @@ commit_file (OstreeRepo      *self,
   GFile *tmp_file = NULL;
   GChecksum *ret_checksum = NULL;
   gboolean did_exist;
+  OstreeObjectType objtype;
 
   g_assert (expected_checksum || out_checksum);
 
@@ -816,7 +834,9 @@ commit_file (OstreeRepo      *self,
         goto out;
     }
 
-  if (!ostree_repo_stage_object (self, OSTREE_OBJECT_TYPE_FILE,
+  objtype = get_objtype_for_repo_file (self);
+
+  if (!ostree_repo_stage_object (self, objtype,
                                  file_info, xattrs, input,
                                  &tmp_file, out_checksum ? &ret_checksum : NULL,
                                  cancellable, error))
@@ -825,7 +845,7 @@ commit_file (OstreeRepo      *self,
   if (expected_checksum == NULL)
     expected_checksum = g_checksum_get_string (ret_checksum);
 
-  if (!commit_staged_file (self, tmp_file, expected_checksum, OSTREE_OBJECT_TYPE_FILE, 
+  if (!commit_staged_file (self, tmp_file, expected_checksum, objtype, 
                            &did_exist, cancellable, error))
     goto out;
   g_clear_object (&tmp_file);
@@ -844,12 +864,12 @@ commit_file (OstreeRepo      *self,
 }
 
 static gboolean
-import_gvariant_object (OstreeRepo  *self,
-                        OstreeSerializedVariantType type,
-                        GVariant       *variant,
-                        GChecksum    **out_checksum,
-                        GCancellable *cancellable,
-                        GError       **error)
+import_gvariant_object (OstreeRepo         *self,
+                        OstreeObjectType    type,
+                        GVariant           *variant,
+                        GChecksum         **out_checksum,
+                        GCancellable       *cancellable,
+                        GError            **error)
 {
   gboolean ret = FALSE;
   GChecksum *ret_checksum = NULL;
@@ -861,7 +881,7 @@ import_gvariant_object (OstreeRepo  *self,
                                              g_variant_get_size (serialized),
                                              NULL);
   
-  if (!stage_and_commit_from_input (self, OSTREE_OBJECT_TYPE_META,
+  if (!stage_and_commit_from_input (self, type,
                                     NULL, NULL, mem,
                                     &ret_checksum,
                                     cancellable, error))
@@ -877,17 +897,22 @@ import_gvariant_object (OstreeRepo  *self,
 }
 
 gboolean
-ostree_repo_load_variant_checked (OstreeRepo  *self,
-                                  OstreeSerializedVariantType expected_type,
-                                  const char    *sha256, 
-                                  GVariant     **out_variant,
-                                  GError       **error)
+ostree_repo_load_variant (OstreeRepo  *self,
+                          OstreeObjectType  expected_type,
+                          const char    *sha256, 
+                          GVariant     **out_variant,
+                          GError       **error)
 {
   gboolean ret = FALSE;
-  OstreeSerializedVariantType type;
+  OstreeObjectType type;
+  GFile *object_path = NULL;
   GVariant *ret_variant = NULL;
 
-  if (!ostree_repo_load_variant (self, sha256, &type, &ret_variant, error))
+  g_return_val_if_fail (OSTREE_OBJECT_TYPE_IS_META (expected_type), FALSE);
+
+  object_path = ostree_repo_get_object_path (self, sha256, expected_type);
+
+  if (!ostree_parse_metadata_file (object_path, &type, &ret_variant, error))
     goto out;
 
   if (type != expected_type)
@@ -901,6 +926,7 @@ ostree_repo_load_variant_checked (OstreeRepo  *self,
   ret = TRUE;
   ot_transfer_out_value(out_variant, &ret_variant);
  out:
+  g_clear_object (&object_path);
   ot_clear_gvariant (&ret_variant);
   return ret;
 }
@@ -922,7 +948,7 @@ import_directory_meta (OstreeRepo   *self,
 
   dirmeta = ostree_create_directory_metadata (file_info, xattrs);
   
-  if (!import_gvariant_object (self, OSTREE_SERIALIZED_DIRMETA_VARIANT, 
+  if (!import_gvariant_object (self, OSTREE_OBJECT_TYPE_DIR_META, 
                                dirmeta, &ret_checksum, cancellable, error))
     goto out;
 
@@ -944,7 +970,7 @@ ostree_repo_get_object_path (OstreeRepo  *self,
   char *relpath;
   GFile *ret;
 
-  relpath = ostree_get_relative_object_path (checksum, type, priv->mode == OSTREE_REPO_MODE_ARCHIVE);
+  relpath = ostree_get_relative_object_path (checksum, type);
   path = g_build_filename (priv->path, relpath, NULL);
   g_free (relpath);
   ret = ot_gfile_new_for_path (path);
@@ -969,7 +995,7 @@ ostree_repo_store_object_trusted (OstreeRepo   *self,
 
   if (!g_file_query_exists (local_object, cancellable))
     { 
-      if (objtype == OSTREE_OBJECT_TYPE_FILE)
+      if (!OSTREE_OBJECT_TYPE_IS_META (objtype))
         {
           if (!commit_file (self, file, checksum, NULL, cancellable, error))
             goto out;
@@ -980,7 +1006,7 @@ ostree_repo_store_object_trusted (OstreeRepo   *self,
           if (!input)
             goto out;
 
-          if (!stage_and_commit_from_input (self, OSTREE_OBJECT_TYPE_META,
+          if (!stage_and_commit_from_input (self, objtype,
                                             NULL, NULL, input,
                                             NULL, cancellable, error))
             goto out;
@@ -1009,22 +1035,26 @@ ostree_repo_store_archived_file (OstreeRepo       *self,
   GFile *src = NULL;
   GInputStream *input = NULL;
   GVariant *xattrs = NULL;
+  OstreeObjectType dest_objtype;
 
   src = ot_gfile_new_for_path (path);
 
-  if (objtype == OSTREE_OBJECT_TYPE_META)
+  if (OSTREE_OBJECT_TYPE_IS_META(objtype))
     {
+      dest_objtype = objtype;
       input = (GInputStream*)g_file_read (src, NULL, error);
       if (!input)
         goto out;
     }
   else
     {
+      /* Ensure we convert archived files to bare, or vice versa */
+      dest_objtype = get_objtype_for_repo_file (self);
       if (!ostree_parse_archived_file (src, &file_info, &xattrs, &input, NULL, error))
         goto out;
     }
 
-  if (!ostree_repo_stage_object (self, objtype,
+  if (!ostree_repo_stage_object (self, dest_objtype,
                                  file_info, xattrs, input,
                                  &tmp_file, &checksum, NULL, error))
     goto out;
@@ -1038,7 +1068,7 @@ ostree_repo_store_archived_file (OstreeRepo       *self,
     }
 
   if (!commit_staged_file (self, tmp_file, g_checksum_get_string (checksum),
-                           objtype, did_exist, NULL, error))
+                           dest_objtype, did_exist, NULL, error))
     goto out;
   g_clear_object (&tmp_file);
 
@@ -1123,7 +1153,7 @@ import_commit (OstreeRepo *self,
                           root_contents_checksum,
                           root_metadata_checksum);
   g_variant_ref_sink (commit);
-  if (!import_gvariant_object (self, OSTREE_SERIALIZED_COMMIT_VARIANT,
+  if (!import_gvariant_object (self, OSTREE_OBJECT_TYPE_COMMIT,
                                commit, &ret_commit, NULL, error))
     goto out;
 
@@ -1208,7 +1238,6 @@ create_tree_variant_from_hashes (GHashTable            *file_checksums,
 
   return serialized_tree;
 }
-                                 
 
 static gboolean
 import_directory_recurse (OstreeRepo           *self,
@@ -1303,7 +1332,7 @@ import_directory_recurse (OstreeRepo           *self,
           if (!xattrs)
             goto out;
 
-          if (!stage_and_commit_from_input (self, OSTREE_OBJECT_TYPE_FILE,
+          if (!stage_and_commit_from_input (self, get_objtype_for_repo_file (self),
                                             child_info, xattrs, file_input,
                                             &child_file_checksum, cancellable, error))
             goto out;
@@ -1324,7 +1353,7 @@ import_directory_recurse (OstreeRepo           *self,
                                                      dir_contents_checksums,
                                                      dir_metadata_checksums);
 
-  if (!import_gvariant_object (self, OSTREE_SERIALIZED_TREE_VARIANT,
+  if (!import_gvariant_object (self, OSTREE_OBJECT_TYPE_DIR_TREE,
                                serialized_tree, &ret_contents_checksum,
                                cancellable, error))
     goto out;
@@ -1462,7 +1491,7 @@ import_libarchive_entry_file (OstreeRepo           *self,
   if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR)
     archive_stream = ostree_libarchive_input_stream_new (a);
   
-  if (!stage_and_commit_from_input (self, OSTREE_OBJECT_TYPE_FILE,
+  if (!stage_and_commit_from_input (self, get_objtype_for_repo_file (self),
                                     file_info, NULL, archive_stream,
                                     &ret_checksum, cancellable, error))
     goto out;
@@ -1582,7 +1611,7 @@ file_tree_import_recurse (OstreeRepo           *self,
                                                      dir_contents_checksums,
                                                      dir_metadata_checksums);
       
-  if (!import_gvariant_object (self, OSTREE_SERIALIZED_TREE_VARIANT,
+  if (!import_gvariant_object (self, OSTREE_OBJECT_TYPE_DIR_TREE,
                                serialized_tree, &ret_contents_checksum_obj,
                                cancellable, error))
     goto out;
@@ -1916,11 +1945,16 @@ iter_object_dir (OstreeRepo             *self,
       if (type == G_FILE_TYPE_DIRECTORY)
         goto loop_out;
       
-      if (g_str_has_suffix (name, ".meta"))
-        objtype = OSTREE_OBJECT_TYPE_META;
-      else if (g_str_has_suffix (name, ".file")
-               || g_str_has_suffix (name, ".archive"))
-        objtype = OSTREE_OBJECT_TYPE_FILE;
+      if (g_str_has_suffix (name, ".file"))
+        objtype = OSTREE_OBJECT_TYPE_RAW_FILE;
+      else if (g_str_has_suffix (name, ".archive"))
+        objtype = OSTREE_OBJECT_TYPE_ARCHIVED_FILE;
+      else if (g_str_has_suffix (name, ".dirtree"))
+        objtype = OSTREE_OBJECT_TYPE_DIR_TREE;
+      else if (g_str_has_suffix (name, ".dirmeta"))
+        objtype = OSTREE_OBJECT_TYPE_DIR_META;
+      else if (g_str_has_suffix (name, ".commit"))
+        objtype = OSTREE_OBJECT_TYPE_COMMIT;
       else
         goto loop_out;
           
@@ -2016,34 +2050,6 @@ ostree_repo_iter_objects (OstreeRepo  *self,
   return ret;
 }
 
-gboolean
-ostree_repo_load_variant (OstreeRepo *self,
-                          const char   *sha256,
-                          OstreeSerializedVariantType *out_type,
-                          GVariant    **out_variant,
-                          GError      **error)
-{
-  gboolean ret = FALSE;
-  OstreeSerializedVariantType ret_type;
-  GVariant *ret_variant = NULL;
-  GFile *f = NULL;
-
-  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
-  f = ostree_repo_get_object_path (self, sha256, OSTREE_OBJECT_TYPE_META);
-  if (!ostree_parse_metadata_file (f, &ret_type, &ret_variant, error))
-    goto out;
-
-  ret = TRUE;
-  if (out_type)
-    *out_type = ret_type;
-  ot_transfer_out_value(out_variant, &ret_variant);
- out:
-  ot_clear_gvariant (&ret_variant);
-  g_clear_object (&f);
-  return ret;
-}
-
 static gboolean
 checkout_file_from_input (GFile          *file,
                           OstreeRepoCheckoutMode mode,
@@ -2070,7 +2076,7 @@ checkout_file_from_input (GFile          *file,
     }
 
   if (!ostree_create_file_from_input (file, temp_info ? temp_info : finfo,
-                                      xattrs, input, OSTREE_OBJECT_TYPE_FILE,
+                                      xattrs, input, OSTREE_OBJECT_TYPE_RAW_FILE,
                                       NULL, cancellable, error))
     goto out;
 
@@ -2137,7 +2143,7 @@ checkout_tree (OstreeRepo               *self,
         {
           const char *checksum = _ostree_repo_file_get_checksum ((OstreeRepoFile*)src_child);
 
-          object_path = ostree_repo_get_object_path (self, checksum, OSTREE_OBJECT_TYPE_FILE);
+          object_path = ostree_repo_get_object_path (self, checksum, get_objtype_for_repo_file (self));
 
           if (priv->mode == OSTREE_REPO_MODE_ARCHIVE)
             {
@@ -2239,7 +2245,7 @@ get_file_checksum (GFile  *f,
     }
   else
     {
-      if (!ostree_checksum_file (f, OSTREE_OBJECT_TYPE_FILE,
+      if (!ostree_checksum_file (f, OSTREE_OBJECT_TYPE_RAW_FILE,
                                  &tmp_checksum, cancellable, error))
         goto out;
       ret_checksum = g_strdup (g_checksum_get_string (tmp_checksum));
diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h
index dc2f224..d01134b 100644
--- a/src/libostree/ostree-repo.h
+++ b/src/libostree/ostree-repo.h
@@ -76,6 +76,9 @@ GFile *       ostree_repo_get_object_path (OstreeRepo   *self,
                                            const char   *object,
                                            OstreeObjectType type);
 
+GFile *       ostree_repo_get_file_object_path (OstreeRepo   *self,
+                                                const char   *object);
+
 gboolean      ostree_repo_store_archived_file (OstreeRepo       *self,
                                                const char       *expected_checksum,
                                                const char       *path,
@@ -102,17 +105,11 @@ gboolean      ostree_repo_write_ref (OstreeRepo  *self,
                                      const char  *rev,
                                      GError     **error);
 
-gboolean      ostree_repo_load_variant (OstreeRepo *self,
-                                          const char   *sha256,
-                                          OstreeSerializedVariantType *out_type,
-                                          GVariant    **out_variant,
-                                          GError      **error);
-
-gboolean      ostree_repo_load_variant_checked (OstreeRepo  *self,
-                                                OstreeSerializedVariantType expected_type,
-                                                const char    *sha256, 
-                                                GVariant     **out_variant,
-                                                GError       **error);
+gboolean      ostree_repo_load_variant (OstreeRepo  *self,
+                                        OstreeObjectType expected_type,
+                                        const char    *sha256, 
+                                        GVariant     **out_variant,
+                                        GError       **error);
 
 gboolean      ostree_repo_commit_directory (OstreeRepo   *self,
                                             const char   *branch,
diff --git a/src/libotutil/ot-gio-utils.c b/src/libotutil/ot-gio-utils.c
index 5f69360..1c8c5dc 100644
--- a/src/libotutil/ot-gio-utils.c
+++ b/src/libotutil/ot-gio-utils.c
@@ -163,6 +163,8 @@ ot_gio_splice_and_checksum (GOutputStream  *out,
   gboolean ret = FALSE;
   GChecksum *ret_checksum = NULL;
 
+  g_return_val_if_fail (out != NULL || out_checksum != NULL, FALSE);
+
   if (out_checksum)
     ret_checksum = g_checksum_new (G_CHECKSUM_SHA256);
   
@@ -176,8 +178,11 @@ ot_gio_splice_and_checksum (GOutputStream  *out,
             goto out;
           if (ret_checksum)
             g_checksum_update (ret_checksum, (guint8*)buf, bytes_read);
-          if (!g_output_stream_write_all (out, buf, bytes_read, &bytes_written, cancellable, error))
-            goto out;
+          if (out)
+            {
+              if (!g_output_stream_write_all (out, buf, bytes_read, &bytes_written, cancellable, error))
+                goto out;
+            }
         }
       while (bytes_read > 0);
     }
@@ -195,6 +200,17 @@ ot_gio_splice_and_checksum (GOutputStream  *out,
 }
 
 gboolean
+ot_gio_checksum_stream (GInputStream   *in,
+                        GChecksum     **out_checksum,
+                        GCancellable   *cancellable,
+                        GError        **error)
+{
+  if (!out_checksum)
+    return TRUE;
+  return ot_gio_splice_and_checksum (NULL, in, out_checksum, cancellable, error);
+}
+
+gboolean
 ot_gfile_merge_dirs (GFile    *destination,
                      GFile    *src,
                      GCancellable *cancellable,
diff --git a/src/libotutil/ot-gio-utils.h b/src/libotutil/ot-gio-utils.h
index a8cc080..ef0f0b3 100644
--- a/src/libotutil/ot-gio-utils.h
+++ b/src/libotutil/ot-gio-utils.h
@@ -51,6 +51,11 @@ gboolean ot_gio_splice_and_checksum (GOutputStream  *out,
                                      GCancellable   *cancellable,
                                      GError        **error);
 
+gboolean ot_gio_checksum_stream (GInputStream   *in,
+                                 GChecksum     **out_checksum,
+                                 GCancellable   *cancellable,
+                                 GError        **error);
+
 gboolean ot_gfile_merge_dirs (GFile    *destination,
                               GFile    *src,
                               GCancellable *cancellable,
diff --git a/src/ostree/ostree-pull.c b/src/ostree/ostree-pull.c
index d75991b..5ca9d13 100644
--- a/src/ostree/ostree-pull.c
+++ b/src/ostree/ostree-pull.c
@@ -126,7 +126,9 @@ store_object (OstreeRepo  *repo,
   char *relpath = NULL;
   SoupURI *obj_uri = NULL;
 
-  objpath = ostree_get_relative_object_path (object, objtype, TRUE);
+  g_assert (objtype != OSTREE_OBJECT_TYPE_RAW_FILE);
+
+  objpath = ostree_get_relative_object_path (object, objtype);
   obj_uri = soup_uri_copy (baseuri);
   relpath = g_build_filename (soup_uri_get_path (obj_uri), objpath, NULL);
   soup_uri_set_path (obj_uri, relpath);
@@ -160,28 +162,19 @@ store_tree_recurse (OstreeRepo   *repo,
   GVariant *tree = NULL;
   GVariant *files_variant = NULL;
   GVariant *dirs_variant = NULL;
-  OstreeSerializedVariantType metatype;
   gboolean did_exist;
   int i, n;
 
-  if (!store_object (repo, soup, base_uri, rev, OSTREE_OBJECT_TYPE_META, &did_exist, error))
+  if (!store_object (repo, soup, base_uri, rev, OSTREE_OBJECT_TYPE_DIR_TREE, &did_exist, error))
     goto out;
 
   if (did_exist)
     log_verbose ("Already have tree %s", rev);
   else
     {
-      if (!ostree_repo_load_variant (repo, rev, &metatype, &tree, error))
+      if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_DIR_TREE, rev, &tree, error))
         goto out;
       
-      if (metatype != OSTREE_SERIALIZED_TREE_VARIANT)
-        {
-          g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                       "Tree metadata '%s' has wrong type %d, expected %d",
-                       rev, metatype, OSTREE_SERIALIZED_TREE_VARIANT);
-          goto out;
-        }
-      
       /* PARSE OSTREE_SERIALIZED_TREE_VARIANT */
       files_variant = g_variant_get_child_value (tree, 2);
       dirs_variant = g_variant_get_child_value (tree, 3);
@@ -194,7 +187,7 @@ store_tree_recurse (OstreeRepo   *repo,
 
           g_variant_get_child (files_variant, i, "(&s&s)", &filename, &checksum);
 
-          if (!store_object (repo, soup, base_uri, checksum, OSTREE_OBJECT_TYPE_FILE, &did_exist, error))
+          if (!store_object (repo, soup, base_uri, checksum, OSTREE_OBJECT_TYPE_ARCHIVED_FILE, &did_exist, error))
             goto out;
         }
       
@@ -208,7 +201,7 @@ store_tree_recurse (OstreeRepo   *repo,
           g_variant_get_child (dirs_variant, i, "(&s&s&s)",
                                &dirname, &tree_checksum, &meta_checksum);
 
-          if (!store_object (repo, soup, base_uri, meta_checksum, OSTREE_OBJECT_TYPE_META, &did_exist, error))
+          if (!store_object (repo, soup, base_uri, meta_checksum, OSTREE_OBJECT_TYPE_DIR_META, &did_exist, error))
             goto out;
 
           if (!store_tree_recurse (repo, soup, base_uri, tree_checksum, error))
@@ -233,34 +226,25 @@ store_commit_recurse (OstreeRepo   *repo,
 {
   gboolean ret = FALSE;
   GVariant *commit = NULL;
-  OstreeSerializedVariantType metatype;
   const char *tree_contents_checksum;
   const char *tree_meta_checksum;
   gboolean did_exist;
 
-  if (!store_object (repo, soup, base_uri, rev, OSTREE_OBJECT_TYPE_META, &did_exist, error))
+  if (!store_object (repo, soup, base_uri, rev, OSTREE_OBJECT_TYPE_COMMIT, &did_exist, error))
     goto out;
 
   if (did_exist)
     log_verbose ("Already have commit %s", rev);
   else
     {
-      if (!ostree_repo_load_variant (repo, rev, &metatype, &commit, error))
+      if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, rev, &commit, error))
         goto out;
       
-      if (metatype != OSTREE_SERIALIZED_COMMIT_VARIANT)
-        {
-          g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                       "Commit '%s' has wrong type %d, expected %d",
-                       rev, metatype, OSTREE_SERIALIZED_COMMIT_VARIANT);
-          goto out;
-        }
-      
       /* PARSE OSTREE_SERIALIZED_COMMIT_VARIANT */
       g_variant_get_child (commit, 6, "&s", &tree_contents_checksum);
       g_variant_get_child (commit, 7, "&s", &tree_meta_checksum);
       
-      if (!store_object (repo, soup, base_uri, tree_meta_checksum, OSTREE_OBJECT_TYPE_META, &did_exist, error))
+      if (!store_object (repo, soup, base_uri, tree_meta_checksum, OSTREE_OBJECT_TYPE_DIR_META, &did_exist, error))
         goto out;
       
       if (!store_tree_recurse (repo, soup, base_uri, tree_contents_checksum, error))
diff --git a/src/ostree/ot-builtin-checksum.c b/src/ostree/ot-builtin-checksum.c
index 4851133..911482e 100644
--- a/src/ostree/ot-builtin-checksum.c
+++ b/src/ostree/ot-builtin-checksum.c
@@ -79,7 +79,7 @@ ostree_builtin_checksum (int argc, char **argv, const char *repo_path, GError **
 
   data.loop = g_main_loop_new (NULL, FALSE);
   data.error = error;
-  ostree_checksum_file_async (f, OSTREE_OBJECT_TYPE_FILE, G_PRIORITY_DEFAULT, NULL, on_checksum_received, &data);
+  ostree_checksum_file_async (f, OSTREE_OBJECT_TYPE_RAW_FILE, G_PRIORITY_DEFAULT, NULL, on_checksum_received, &data);
   
   g_main_loop_run (data.loop);
 
diff --git a/src/ostree/ot-builtin-fsck.c b/src/ostree/ot-builtin-fsck.c
index 311b0c8..033a8ec 100644
--- a/src/ostree/ot-builtin-fsck.c
+++ b/src/ostree/ot-builtin-fsck.c
@@ -123,7 +123,7 @@ object_iter_callback (OstreeRepo    *repo,
      g_printerr ("note: floating object: %s\n", path); */
 
   if (ostree_repo_get_mode (repo) == OSTREE_REPO_MODE_ARCHIVE
-      && objtype == OSTREE_OBJECT_TYPE_FILE)
+      && !OSTREE_OBJECT_TYPE_IS_META (objtype))
     {
       if (!g_str_has_suffix (path, ".archive"))
         {
diff --git a/src/ostree/ot-builtin-init.c b/src/ostree/ot-builtin-init.c
index 7c9fd95..96bf67f 100644
--- a/src/ostree/ot-builtin-init.c
+++ b/src/ostree/ot-builtin-init.c
@@ -59,8 +59,7 @@ ostree_builtin_init (int argc, char **argv, const char *repo_path, GError **erro
   child = g_file_get_child (repodir, "config");
 
   config_data = g_string_new (DEFAULT_CONFIG_CONTENTS);
-  if (archive)
-    g_string_append_printf (config_data, "mode=%s\n", archive ? "archive" : "bare");
+  g_string_append_printf (config_data, "mode=%s\n", archive ? "archive" : "bare");
   if (!g_file_replace_contents (child,
                                 config_data->str,
                                 config_data->len,
diff --git a/src/ostree/ot-builtin-log.c b/src/ostree/ot-builtin-log.c
index 41a1ae5..9fa7b02 100644
--- a/src/ostree/ot-builtin-log.c
+++ b/src/ostree/ot-builtin-log.c
@@ -69,7 +69,7 @@ ostree_builtin_log (int argc, char **argv, const char *repo_path, GError **error
 
   while (TRUE)
     {
-      OstreeSerializedVariantType type;
+      OstreeObjectType type;
       char *formatted = NULL;
       guint32 version;
       const char *parent;
@@ -86,7 +86,7 @@ ostree_builtin_log (int argc, char **argv, const char *repo_path, GError **error
       char *formatted_metadata = NULL;
       
       ot_clear_gvariant (&commit);
-      if (!ostree_repo_load_variant (repo, resolved_rev, &type, &commit, error))
+      if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, resolved_rev, &commit, error))
         goto out;
 
       /* Ignore commit metadata for now */
diff --git a/src/ostree/ot-builtin-show.c b/src/ostree/ot-builtin-show.c
index 45ef2ae..ab5b5c7 100644
--- a/src/ostree/ot-builtin-show.c
+++ b/src/ostree/ot-builtin-show.c
@@ -86,18 +86,60 @@ show_repo_meta (OstreeRepo  *repo,
                 const char *resolved_rev,
                 GError **error)
 {
-  OstreeSerializedVariantType type;
   gboolean ret = FALSE;
   GVariant *variant = NULL;
+  GFile *object_path = NULL;
+  GInputStream *in = NULL;
+  char buf[8192];
+  gsize bytes_read;
+  OstreeObjectType objtype;
+
+  for (objtype = OSTREE_OBJECT_TYPE_RAW_FILE; objtype <= OSTREE_OBJECT_TYPE_COMMIT; objtype++)
+    {
+      g_clear_object (&object_path);
+      
+      object_path = ostree_repo_get_object_path (repo, resolved_rev, objtype);
+      
+      if (!g_file_query_exists (object_path, NULL))
+        continue;
+      
+      if (OSTREE_OBJECT_TYPE_IS_META (objtype))
+        {
+          if (!ostree_repo_load_variant (repo, objtype, resolved_rev, &variant, error))
+            continue;
+
+          g_print ("Object: %s\nType: %d\n", resolved_rev, objtype);
+          print_variant (variant);
+          break;
+        }
+      else if (objtype == OSTREE_OBJECT_TYPE_RAW_FILE)
+        {
+          in = (GInputStream*)g_file_read (object_path, NULL, error);
+          if (!in)
+            continue;
+
+          do {
+            if (!g_input_stream_read_all (in, buf, sizeof (buf), &bytes_read, NULL, error))
+              goto out;
+            g_print ("%s", buf);
+          } while (bytes_read > 0);
+        }
+      else if (objtype == OSTREE_OBJECT_TYPE_ARCHIVED_FILE)
+        {
+          g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+                       "Can't show archived files yet");
+          goto out;
+        }
+      else
+        g_assert_not_reached ();
+    }
 
-  if (!ostree_repo_load_variant (repo, resolved_rev, &type, &variant, error))
-    goto out;
-  g_print ("Object: %s\nType: %d\n", resolved_rev, type);
-  print_variant (variant);
 
   ret = TRUE;
  out:
   ot_clear_gvariant (&variant);
+  g_clear_object (&in);
+  g_clear_object (&object_path);
   return ret;
 }
 
@@ -116,8 +158,8 @@ do_print_compose (OstreeRepo  *repo,
   const char *branch;
   const char *branchrev;
 
-  if (!ostree_repo_load_variant_checked (repo, OSTREE_SERIALIZED_COMMIT_VARIANT,
-                                         resolved_rev, &variant, error))
+  if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT,
+                                 resolved_rev, &variant, error))
     goto out;
       
   /* PARSE OSTREE_SERIALIZED_COMMIT_VARIANT */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]