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.
This commit is contained in:
parent
db9b7b7be6
commit
b8e8b58585
|
|
@ -42,7 +42,7 @@ ostree_validate_checksum_string (const char *sha256,
|
|||
}
|
||||
|
||||
GVariant *
|
||||
ostree_wrap_metadata_variant (OstreeSerializedVariantType type,
|
||||
ostree_wrap_metadata_variant (OstreeObjectType type,
|
||||
GVariant *metadata)
|
||||
{
|
||||
return g_variant_new ("(uv)", GUINT32_TO_BE ((guint32)type), metadata);
|
||||
|
|
@ -180,110 +180,6 @@ 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 ret = FALSE;
|
||||
GVariant *dirmeta = NULL;
|
||||
GVariant *packed = NULL;
|
||||
GChecksum *ret_checksum = NULL;
|
||||
|
||||
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));
|
||||
|
||||
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;
|
||||
|
||||
content_sha256 = g_checksum_new (G_CHECKSUM_SHA256);
|
||||
|
||||
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)
|
||||
{
|
||||
guint8 buf[8192];
|
||||
|
||||
while ((bytes_read = g_input_stream_read (input, buf, sizeof (buf), cancellable, error)) > 0)
|
||||
g_checksum_update (content_sha256, buf, bytes_read);
|
||||
if (bytes_read < 0)
|
||||
goto out;
|
||||
}
|
||||
else if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_SYMBOLIC_LINK)
|
||||
{
|
||||
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));
|
||||
}
|
||||
else if (S_ISCHR(unix_mode) || S_ISBLK(unix_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);
|
||||
}
|
||||
else if (S_ISFIFO(unix_mode))
|
||||
{
|
||||
g_assert (objtype == OSTREE_OBJECT_TYPE_FILE);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR,
|
||||
G_IO_ERROR_FAILED,
|
||||
"Unsupported file (must be regular, symbolic link, fifo, or character/block device)");
|
||||
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));
|
||||
}
|
||||
|
||||
ot_transfer_out_value(out_checksum, &content_and_meta_sha256);
|
||||
ret = TRUE;
|
||||
out:
|
||||
ot_clear_checksum (&content_sha256);
|
||||
ot_clear_checksum (&content_and_meta_sha256);
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_checksum_file_from_input (GFileInfo *file_info,
|
||||
GVariant *xattrs,
|
||||
|
|
@ -293,15 +189,77 @@ ostree_checksum_file_from_input (GFileInfo *file_info,
|
|||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GChecksum *ret_checksum = NULL;
|
||||
GVariant *dirmeta = NULL;
|
||||
GVariant *packed = NULL;
|
||||
guint8 buf[8192];
|
||||
gsize bytes_read;
|
||||
guint32 mode;
|
||||
|
||||
if (OSTREE_OBJECT_TYPE_IS_META (objtype))
|
||||
return ot_gio_checksum_stream (in, out_checksum, cancellable, error);
|
||||
|
||||
ret_checksum = g_checksum_new (G_CHECKSUM_SHA256);
|
||||
|
||||
mode = g_file_info_get_attribute_uint32 (file_info, "unix::mode");
|
||||
|
||||
if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY)
|
||||
{
|
||||
return checksum_directory (file_info, xattrs, out_checksum, cancellable, error);
|
||||
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));
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
else if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_SYMBOLIC_LINK)
|
||||
{
|
||||
const char *symlink_target = g_file_info_get_symlink_target (file_info);
|
||||
|
||||
g_assert (symlink_target != NULL);
|
||||
|
||||
g_checksum_update (ret_checksum, (guint8*)symlink_target, strlen (symlink_target));
|
||||
}
|
||||
else if (S_ISCHR(mode) || S_ISBLK(mode))
|
||||
{
|
||||
guint32 rdev = g_file_info_get_attribute_uint32 (file_info, "unix::rdev");
|
||||
rdev = GUINT32_TO_BE (rdev);
|
||||
g_checksum_update (ret_checksum, (guint8*)&rdev, 4);
|
||||
}
|
||||
else if (S_ISFIFO(mode))
|
||||
{
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
return checksum_nondirectory (file_info, xattrs, in, objtype,
|
||||
out_checksum, cancellable, error);
|
||||
g_set_error (error, G_IO_ERROR,
|
||||
G_IO_ERROR_FAILED,
|
||||
"Unsupported file (must be regular, symbolic link, fifo, or character/block device)");
|
||||
goto out;
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
ret = TRUE;
|
||||
ot_transfer_out_value (out_checksum, &ret_checksum);
|
||||
out:
|
||||
ot_clear_checksum (&ret_checksum);
|
||||
ot_clear_gvariant (&dirmeta);
|
||||
ot_clear_gvariant (&packed);
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
@ -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
|
||||
case OSTREE_OBJECT_TYPE_RAW_FILE:
|
||||
type_string = ".file";
|
||||
break;
|
||||
case OSTREE_OBJECT_TYPE_META:
|
||||
type_string = ".meta";
|
||||
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_COMMIT:
|
||||
type_string = ".commit";
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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)"
|
||||
|
||||
|
|
@ -93,20 +91,18 @@ 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);
|
||||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -172,20 +172,20 @@ do_resolve_commit (OstreeRepoFile *self,
|
|||
|
||||
g_assert (self->parent == NULL);
|
||||
|
||||
if (!ostree_repo_load_variant_checked (self->repo, OSTREE_SERIALIZED_COMMIT_VARIANT,
|
||||
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,
|
||||
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,
|
||||
if (!ostree_repo_load_variant (self->repo, OSTREE_OBJECT_TYPE_DIR_META,
|
||||
tree_meta_checksum, &root_metadata,
|
||||
error))
|
||||
goto out;
|
||||
|
|
@ -241,12 +241,12 @@ 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,
|
||||
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,
|
||||
if (!ostree_repo_load_variant (self->repo, OSTREE_OBJECT_TYPE_DIR_META,
|
||||
metadata_checksum, &tree_metadata,
|
||||
error))
|
||||
goto out;
|
||||
|
|
@ -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,7 +724,7 @@ 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,
|
||||
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_DIR_META,
|
||||
metadata_checksum, &metadata, error))
|
||||
goto out;
|
||||
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -845,7 +865,7 @@ commit_file (OstreeRepo *self,
|
|||
|
||||
static gboolean
|
||||
import_gvariant_object (OstreeRepo *self,
|
||||
OstreeSerializedVariantType type,
|
||||
OstreeObjectType type,
|
||||
GVariant *variant,
|
||||
GChecksum **out_checksum,
|
||||
GCancellable *cancellable,
|
||||
|
|
@ -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,
|
||||
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;
|
||||
|
||||
|
|
@ -1209,7 +1239,6 @@ create_tree_variant_from_hashes (GHashTable *file_checksums,
|
|||
return serialized_tree;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
import_directory_recurse (OstreeRepo *self,
|
||||
GFile *base,
|
||||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
@ -103,13 +106,7 @@ gboolean ostree_repo_write_ref (OstreeRepo *self,
|
|||
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,
|
||||
OstreeObjectType expected_type,
|
||||
const char *sha256,
|
||||
GVariant **out_variant,
|
||||
GError **error);
|
||||
|
|
|
|||
|
|
@ -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,9 +178,12 @@ ot_gio_splice_and_checksum (GOutputStream *out,
|
|||
goto out;
|
||||
if (ret_checksum)
|
||||
g_checksum_update (ret_checksum, (guint8*)buf, bytes_read);
|
||||
if (out)
|
||||
{
|
||||
if (!g_output_stream_write_all (out, buf, bytes_read, &bytes_written, cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
while (bytes_read > 0);
|
||||
}
|
||||
else
|
||||
|
|
@ -194,6 +199,17 @@ ot_gio_splice_and_checksum (GOutputStream *out,
|
|||
return ret;
|
||||
}
|
||||
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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"))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ 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");
|
||||
if (!g_file_replace_contents (child,
|
||||
config_data->str,
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
if (!ostree_repo_load_variant (repo, resolved_rev, &type, &variant, error))
|
||||
goto out;
|
||||
g_print ("Object: %s\nType: %d\n", resolved_rev, type);
|
||||
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 ();
|
||||
}
|
||||
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
ot_clear_gvariant (&variant);
|
||||
g_clear_object (&in);
|
||||
g_clear_object (&object_path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +158,7 @@ do_print_compose (OstreeRepo *repo,
|
|||
const char *branch;
|
||||
const char *branchrev;
|
||||
|
||||
if (!ostree_repo_load_variant_checked (repo, OSTREE_SERIALIZED_COMMIT_VARIANT,
|
||||
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT,
|
||||
resolved_rev, &variant, error))
|
||||
goto out;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue