summaryrefslogtreecommitdiff
path: root/gio
diff options
context:
space:
mode:
authorHyunjee Kim <hj0426.kim@samsung.com>2019-12-03 11:03:29 +0900
committerHyunjee Kim <hj0426.kim@samsung.com>2019-12-03 11:03:29 +0900
commit5a5a730136a5f0ddc9f83e305e9a22c3af38ed67 (patch)
tree840562c9b29e7ea00b878280b3e3255783bb58f1 /gio
parentb2e043716ea7684e40ded43dac699a2a926afef6 (diff)
downloadglib-5a5a730136a5f0ddc9f83e305e9a22c3af38ed67.tar.gz
glib-5a5a730136a5f0ddc9f83e305e9a22c3af38ed67.tar.bz2
glib-5a5a730136a5f0ddc9f83e305e9a22c3af38ed67.zip
Imported Upstream version 2.62.1
Diffstat (limited to 'gio')
-rw-r--r--gio/gfile.c31
-rw-r--r--gio/gfileinfo.c2
-rw-r--r--gio/meson.build2
-rw-r--r--gio/xdgmime/xdgmimecache.c4
4 files changed, 29 insertions, 10 deletions
diff --git a/gio/gfile.c b/gio/gfile.c
index 321153e87..ba93f7c75 100644
--- a/gio/gfile.c
+++ b/gio/gfile.c
@@ -3188,6 +3188,7 @@ file_copy_fallback (GFile *source,
const char *target;
char *attrs_to_read;
gboolean do_set_attributes = FALSE;
+ GFileCreateFlags create_flags;
/* need to know the file type */
info = g_file_query_info (source,
@@ -3277,19 +3278,38 @@ file_copy_fallback (GFile *source,
*
* If a future API like g_file_replace_with_info() is added, switch
* this code to use that.
+ *
+ * Use %G_FILE_CREATE_PRIVATE unless
+ * - we were told to create the file with default permissions (i.e. the
+ * process’ umask),
+ * - or if the source file is on a file system which doesn’t support
+ * `unix::mode` (in which case it probably also makes sense to create the
+ * destination with default permissions because the source cannot be
+ * private),
+ * - or if the destination file is a `GLocalFile`, in which case we can
+ * directly open() it with the permissions from the source file.
*/
+ create_flags = G_FILE_CREATE_NONE;
+ if (!(flags & G_FILE_COPY_TARGET_DEFAULT_PERMS) &&
+ g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_UNIX_MODE) &&
+ !G_IS_LOCAL_FILE (destination))
+ create_flags |= G_FILE_CREATE_PRIVATE;
+ if (flags & G_FILE_COPY_OVERWRITE)
+ create_flags |= G_FILE_CREATE_REPLACE_DESTINATION;
+
if (G_IS_LOCAL_FILE (destination))
{
if (flags & G_FILE_COPY_OVERWRITE)
out = (GOutputStream*)_g_local_file_output_stream_replace (_g_local_file_get_filename (G_LOCAL_FILE (destination)),
FALSE, NULL,
flags & G_FILE_COPY_BACKUP,
- G_FILE_CREATE_REPLACE_DESTINATION |
- G_FILE_CREATE_PRIVATE, info,
+ create_flags,
+ (flags & G_FILE_COPY_TARGET_DEFAULT_PERMS) ? NULL : info,
cancellable, error);
else
out = (GOutputStream*)_g_local_file_output_stream_create (_g_local_file_get_filename (G_LOCAL_FILE (destination)),
- FALSE, G_FILE_CREATE_PRIVATE, info,
+ FALSE, create_flags,
+ (flags & G_FILE_COPY_TARGET_DEFAULT_PERMS) ? NULL : info,
cancellable, error);
}
else if (flags & G_FILE_COPY_OVERWRITE)
@@ -3297,13 +3317,12 @@ file_copy_fallback (GFile *source,
out = (GOutputStream *)g_file_replace (destination,
NULL,
flags & G_FILE_COPY_BACKUP,
- G_FILE_CREATE_REPLACE_DESTINATION |
- G_FILE_CREATE_PRIVATE,
+ create_flags,
cancellable, error);
}
else
{
- out = (GOutputStream *)g_file_create (destination, G_FILE_CREATE_PRIVATE, cancellable, error);
+ out = (GOutputStream *)g_file_create (destination, create_flags, cancellable, error);
}
if (!out)
diff --git a/gio/gfileinfo.c b/gio/gfileinfo.c
index ab4cbea96..032d21144 100644
--- a/gio/gfileinfo.c
+++ b/gio/gfileinfo.c
@@ -1822,7 +1822,7 @@ g_file_info_get_modification_date_time (GFileInfo *info)
if (value_usec == NULL)
return g_steal_pointer (&dt);
- dt2 = g_date_time_add_seconds (dt, _g_file_attribute_value_get_uint32 (value_usec) / (gdouble) G_USEC_PER_SEC);
+ dt2 = g_date_time_add (dt, _g_file_attribute_value_get_uint32 (value_usec));
g_date_time_unref (dt);
return g_steal_pointer (&dt2);
diff --git a/gio/meson.build b/gio/meson.build
index 9a9e621b3..173000f4b 100644
--- a/gio/meson.build
+++ b/gio/meson.build
@@ -1009,8 +1009,6 @@ if enable_systemtap
endif
subdir('fam')
-# Don’t build the tests unless we can run them (either natively or in an exe wrapper)
-build_tests = not meson.is_cross_build() or (meson.is_cross_build() and meson.has_exe_wrapper())
if build_tests
subdir('tests')
endif
diff --git a/gio/xdgmime/xdgmimecache.c b/gio/xdgmime/xdgmimecache.c
index 8010f9e5b..769b57836 100644
--- a/gio/xdgmime/xdgmimecache.c
+++ b/gio/xdgmime/xdgmimecache.c
@@ -965,7 +965,9 @@ _xdg_mime_cache_mime_type_subclass (const char *mime,
for (j = 0; j < n_parents; j++)
{
parent_offset = GET_UINT32 (cache->buffer, offset + 4 + 4 * j);
- if (_xdg_mime_cache_mime_type_subclass (cache->buffer + parent_offset, ubase))
+ if (strcmp (cache->buffer + parent_offset, mime) != 0 &&
+ strcmp (cache->buffer + parent_offset, umime) != 0 &&
+ _xdg_mime_cache_mime_type_subclass (cache->buffer + parent_offset, ubase))
return 1;
}