From f861ba48955b6c3a3a05cdadae510695db3b5a99 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Tue, 29 Oct 2013 09:26:45 +0100 Subject: shutil: Make gs_shutil_cp_a copy ownership as well Like cp -a gs_shutil_cp_a should really copy all directory metadata. This adds support for at least copying the ownership metadata (user/group). https://bugzilla.gnome.org/show_bug.cgi?id=711057 --- gsystem-shutil.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gsystem-shutil.c b/gsystem-shutil.c index a8dbc18..8416033 100644 --- a/gsystem-shutil.c +++ b/gsystem-shutil.c @@ -81,6 +81,16 @@ cp_internal_one_item (GFile *src, goto out; } + if (chown (gs_file_get_path_cached (dest_child), + g_file_info_get_attribute_uint32 (file_info, "unix::uid"), + g_file_info_get_attribute_uint32 (file_info, "unix::gid")) == -1) + { + int errsv = errno; + g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (errsv), + g_strerror (errsv)); + goto out; + } + if (!cp_internal (src_child, dest_child, use_hardlinks, cancellable, error)) goto out; } @@ -132,7 +142,7 @@ cp_internal (GFile *src, GFileInfo *file_info = NULL; GError *temp_error = NULL; - enumerator = g_file_enumerate_children (src, "standard::type,standard::name,unix::mode", + enumerator = g_file_enumerate_children (src, "standard::type,standard::name,unix::uid,unix::gid,unix::mode", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error); if (!enumerator) -- cgit v1.2.1