diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c index 947bc6dc..f2887266 100644 --- a/src/libostree/ostree-core.c +++ b/src/libostree/ostree-core.c @@ -151,13 +151,17 @@ read_xattr_name_array (const char *path, return ret; } -GVariant * -ostree_get_xattrs_for_file (GFile *f, - GError **error) +gboolean +ostree_get_xattrs_for_file (GFile *f, + GVariant **out_xattrs, + GCancellable *cancellable, + GError **error) { + gboolean ret = FALSE; const char *path; - GVariant *ret = NULL; + GVariant *ret_xattrs = NULL; GVariantBuilder builder; + gboolean builder_initialized = FALSE; char *xattr_names = NULL; char *xattr_names_canonical = NULL; ssize_t bytes_read; @@ -165,6 +169,7 @@ ostree_get_xattrs_for_file (GFile *f, path = ot_gfile_get_path_cached (f); g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ayay)")); + builder_initialized = TRUE; bytes_read = llistxattr (path, NULL, 0); @@ -190,10 +195,13 @@ ostree_get_xattrs_for_file (GFile *f, goto out; } - ret = g_variant_builder_end (&builder); - g_variant_ref_sink (ret); + ret_xattrs = g_variant_builder_end (&builder); + g_variant_ref_sink (ret_xattrs); + + ret = TRUE; + ot_transfer_out_value (out_xattrs, &ret_xattrs); out: - if (!ret) + if (!builder_initialized) g_variant_builder_clear (&builder); g_free (xattr_names); g_free (xattr_names_canonical); @@ -316,8 +324,7 @@ ostree_checksum_file (GFile *f, if (objtype == OSTREE_OBJECT_TYPE_RAW_FILE) { - xattrs = ostree_get_xattrs_for_file (f, error); - if (!xattrs) + if (!ostree_get_xattrs_for_file (f, &xattrs, cancellable, error)) goto out; } diff --git a/src/libostree/ostree-core.h b/src/libostree/ostree-core.h index 1df8a6ae..5c578d4f 100644 --- a/src/libostree/ostree-core.h +++ b/src/libostree/ostree-core.h @@ -178,8 +178,10 @@ void ostree_object_from_string (const char *str, char *ostree_get_relative_object_path (const char *checksum, OstreeObjectType type); -GVariant *ostree_get_xattrs_for_file (GFile *f, - GError **error); +gboolean ostree_get_xattrs_for_file (GFile *f, + GVariant **out_xattrs, + GCancellable *cancellable, + GError **error); GVariant *ostree_wrap_metadata_variant (OstreeObjectType type, GVariant *metadata); diff --git a/src/libostree/ostree-repo-file.c b/src/libostree/ostree-repo-file.c index ac4b1292..d81adbeb 100644 --- a/src/libostree/ostree-repo-file.c +++ b/src/libostree/ostree-repo-file.c @@ -317,7 +317,8 @@ ostree_repo_file_get_xattrs (OstreeRepoFile *self, else { local_file = ostree_repo_file_nontree_get_local (self); - ret_xattrs = ostree_get_xattrs_for_file (local_file, error); + if (!ostree_get_xattrs_for_file (local_file, &ret_xattrs, cancellable, error)) + goto out; } ret = TRUE; diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c index 651a44f2..84b8a231 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -2324,8 +2324,7 @@ stage_directory_to_mtree_internal (OstreeRepo *self, { if (!(modifier && modifier->skip_xattrs)) { - xattrs = ostree_get_xattrs_for_file (dir, error); - if (!xattrs) + if (!ostree_get_xattrs_for_file (dir, &xattrs, cancellable, error)) goto out; } @@ -2394,8 +2393,7 @@ stage_directory_to_mtree_internal (OstreeRepo *self, if (!(modifier && modifier->skip_xattrs)) { - xattrs = ostree_get_xattrs_for_file (child, error); - if (!xattrs) + if (!ostree_get_xattrs_for_file (child, &xattrs, cancellable, error)) goto out; } @@ -3239,8 +3237,7 @@ ostree_repo_load_file (OstreeRepo *self, } if (out_xattrs) { - ret_xattrs = ostree_get_xattrs_for_file (content_loose_path, error); - if (!ret_xattrs) + if (!ostree_get_xattrs_for_file (content_loose_path, &ret_xattrs, cancellable,error)) goto out; } } diff --git a/src/ostree/ot-builtin-local-clone.c b/src/ostree/ot-builtin-local-clone.c index 1c9a3d0e..7f2d5aa9 100644 --- a/src/ostree/ot-builtin-local-clone.c +++ b/src/ostree/ot-builtin-local-clone.c @@ -121,7 +121,10 @@ import_loose_object (OtLocalCloneData *data, goto out; if (objtype == OSTREE_OBJECT_TYPE_RAW_FILE) - xattrs = ostree_get_xattrs_for_file (objfile, error); + { + if (!ostree_get_xattrs_for_file (objfile, &xattrs, cancellable, error)) + goto out; + } if (objtype == OSTREE_OBJECT_TYPE_ARCHIVED_FILE_CONTENT) ;