[ostree] core: Tweak dir metadata importing code for libarchive work
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] core: Tweak dir metadata importing code for libarchive work
- Date: Fri, 2 Dec 2011 00:46:36 +0000 (UTC)
commit f98e2a2ddb4026042f7aa142d459ee7c5cb8e3bc
Author: Colin Walters <walters verbum org>
Date: Thu Dec 1 19:37:47 2011 -0500
core: Tweak dir metadata importing code for libarchive work
This will allow us to share a bit more code.
src/libostree/ostree-core.c | 30 ++++++++++--------------------
src/libostree/ostree-core.h | 7 ++-----
src/libostree/ostree-repo.c | 41 ++++++++++++++++++++---------------------
3 files changed, 32 insertions(+), 46 deletions(-)
---
diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c
index a0fe8bd..91cf299 100644
--- a/src/libostree/ostree-core.c
+++ b/src/libostree/ostree-core.c
@@ -190,10 +190,14 @@ checksum_directory (GFile *f,
gboolean ret = FALSE;
GVariant *dirmeta = NULL;
GVariant *packed = NULL;
+ GVariant *xattrs = NULL;
GChecksum *ret_checksum = NULL;
- if (!ostree_get_directory_metadata (f, f_info, &dirmeta, cancellable, error))
+ xattrs = ostree_get_xattrs_for_file (f, error);
+ if (!xattrs)
goto out;
+
+ 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),
@@ -206,6 +210,7 @@ checksum_directory (GFile *f,
ot_clear_checksum (&ret_checksum);
ot_clear_gvariant (&dirmeta);
ot_clear_gvariant (&packed);
+ ot_clear_gvariant (&xattrs);
return ret;
}
@@ -421,21 +426,12 @@ ostree_checksum_file_async_finish (GFile *f,
return TRUE;
}
-gboolean
-ostree_get_directory_metadata (GFile *dir,
- GFileInfo *dir_info,
- GVariant **out_metadata,
- GCancellable *cancellable,
- GError **error)
+GVariant *
+ostree_create_directory_metadata (GFileInfo *dir_info,
+ GVariant *xattrs)
{
- gboolean ret = FALSE;
- GVariant *xattrs = NULL;
GVariant *ret_metadata = NULL;
- xattrs = ostree_get_xattrs_for_file (dir, error);
- if (!xattrs)
- goto out;
-
ret_metadata = g_variant_new ("(uuuu a(ayay))",
OSTREE_DIR_META_VERSION,
GUINT32_TO_BE (g_file_info_get_attribute_uint32 (dir_info, "unix::uid")),
@@ -444,13 +440,7 @@ ostree_get_directory_metadata (GFile *dir,
xattrs);
g_variant_ref_sink (ret_metadata);
- ret = TRUE;
- *out_metadata = ret_metadata;
- ret_metadata = NULL;
- out:
- ot_clear_gvariant (&ret_metadata);
- ot_clear_gvariant (&xattrs);
- return ret;
+ return ret_metadata;
}
gboolean
diff --git a/src/libostree/ostree-core.h b/src/libostree/ostree-core.h
index 640ec71..5318deb 100644
--- a/src/libostree/ostree-core.h
+++ b/src/libostree/ostree-core.h
@@ -128,11 +128,8 @@ gboolean ostree_checksum_file_async_finish (GFile *f,
GChecksum **out_checksum,
GError **error);
-gboolean ostree_get_directory_metadata (GFile *dir,
- GFileInfo *dir_info,
- GVariant **out_metadata,
- GCancellable *cancellable,
- GError **error);
+GVariant *ostree_create_directory_metadata (GFileInfo *dir_info,
+ GVariant *xattrs);
/* Packed files:
*
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index c1ff605..e4a6c92 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -735,44 +735,30 @@ ostree_repo_load_variant_checked (OstreeRepo *self,
}
static gboolean
-import_directory_meta (OstreeRepo *self,
- GFile *f,
- GVariant **out_variant,
- GChecksum **out_checksum,
+import_directory_meta (OstreeRepo *self,
+ GFileInfo *file_info,
+ GVariant *xattrs,
+ GChecksum **out_checksum,
GCancellable *cancellable,
- GError **error)
+ GError **error)
{
gboolean ret = FALSE;
GChecksum *ret_checksum = NULL;
GVariant *dirmeta = NULL;
- GFileInfo *f_info = NULL;
- f_info = g_file_query_info (f, OSTREE_GIO_FAST_QUERYINFO,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- cancellable, error);
- if (!f_info)
- goto out;
-
- if (!ostree_get_directory_metadata (f, f_info, &dirmeta, cancellable, error))
- goto out;
+ dirmeta = ostree_create_directory_metadata (file_info, xattrs);
if (!import_gvariant_object (self, OSTREE_SERIALIZED_DIRMETA_VARIANT,
dirmeta, &ret_checksum, cancellable, error))
goto out;
ret = TRUE;
- if (out_variant)
- {
- *out_variant = dirmeta;
- dirmeta = NULL;
- }
if (out_checksum)
{
*out_checksum = ret_checksum;
ret_checksum = NULL;
}
out:
- g_clear_object (&f_info);
ot_clear_checksum (&ret_checksum);
ot_clear_gvariant (&dirmeta);
return ret;
@@ -1114,12 +1100,25 @@ import_directory_recurse (OstreeRepo *self,
GHashTableIter hash_iter;
GSList *sorted_filenames = NULL;
GSList *iter;
+ GVariant *dir_xattrs = NULL;
GVariant *serialized_tree = NULL;
gpointer key, value;
- if (!import_directory_meta (self, dir, NULL, &ret_metadata_checksum, cancellable, error))
+ child_info = g_file_query_info (dir, OSTREE_GIO_FAST_QUERYINFO,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ cancellable, error);
+ if (!child_info)
goto out;
+ dir_xattrs = ostree_get_xattrs_for_file (dir, error);
+ if (!dir_xattrs)
+ goto out;
+
+ if (!import_directory_meta (self, child_info, dir_xattrs, &ret_metadata_checksum, cancellable, error))
+ goto out;
+
+ g_clear_object (&child_info);
+
dir_enum = g_file_enumerate_children ((GFile*)dir, OSTREE_GIO_FAST_QUERYINFO,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]