From 8c473c5353347fe8ca1612120df40b831c0c9547 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 6 Mar 2023 14:36:26 +0000 Subject: [PATCH 1/3] glocalfile: Set various file attributes if their value is FALSE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Following on from #2907, set various boolean attributes if they have been requested, or are known for sure, and their value is `FALSE`. Previously the `FALSE` value would have been implicitly returned by the getter function, but now doing that without the attribute being explicitly set will trigger a critical warning. *Don’t* set these attributes if their value is unknown or there was an error querying it. Signed-off-by: Philip Withnall Fixes: #2934 --- gio/glocalfile.c | 6 +++--- gio/glocalfileinfo.c | 21 ++++++++++----------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/gio/glocalfile.c b/gio/glocalfile.c index 2b43ff47c..c569b0c1b 100644 --- a/gio/glocalfile.c +++ b/gio/glocalfile.c @@ -845,10 +845,10 @@ get_mount_info (GFileInfo *fs_info, G_UNLOCK (mount_info_hash); } - if (mount_info & MOUNT_INFO_READONLY && - g_file_attribute_matcher_matches (matcher, + if (g_file_attribute_matcher_matches (matcher, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY)) - g_file_info_set_attribute_boolean (fs_info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, TRUE); + g_file_info_set_attribute_boolean (fs_info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, + (mount_info & MOUNT_INFO_READONLY)); if (g_file_attribute_matcher_matches (matcher, G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE)) diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c index 7b9e90b8f..6bc2d4199 100644 --- a/gio/glocalfileinfo.c +++ b/gio/glocalfileinfo.c @@ -2053,17 +2053,16 @@ _g_local_file_info_get (const char *basename, (stat_ok && S_ISREG (_g_stat_mode (&statbuf)))) _g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_STANDARD_IS_BACKUP, TRUE); #else - if (statbuf.attributes & FILE_ATTRIBUTE_HIDDEN) - g_file_info_set_is_hidden (info, TRUE); + g_file_info_set_is_hidden (info, (statbuf.attributes & FILE_ATTRIBUTE_HIDDEN)); - if (statbuf.attributes & FILE_ATTRIBUTE_ARCHIVE) - _g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_DOS_IS_ARCHIVE, TRUE); + _g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_DOS_IS_ARCHIVE, + (statbuf.attributes & FILE_ATTRIBUTE_ARCHIVE)); - if (statbuf.attributes & FILE_ATTRIBUTE_SYSTEM) - _g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_DOS_IS_SYSTEM, TRUE); + _g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_DOS_IS_SYSTEM, + (statbuf.attributes & FILE_ATTRIBUTE_SYSTEM)); - if (statbuf.reparse_tag == IO_REPARSE_TAG_MOUNT_POINT) - _g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_DOS_IS_MOUNTPOINT, TRUE); + _g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_DOS_IS_MOUNTPOINT, + (statbuf.reparse_tag == IO_REPARSE_TAG_MOUNT_POINT)); if (statbuf.reparse_tag != 0) _g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_DOS_REPARSE_POINT_TAG, statbuf.reparse_tag); @@ -2182,9 +2181,9 @@ _g_local_file_info_get (const char *basename, } if (stat_ok && parent_info && parent_info->device != 0 && - _g_file_attribute_matcher_matches_id (attribute_matcher, G_FILE_ATTRIBUTE_ID_UNIX_IS_MOUNTPOINT) && - (_g_stat_dev (&statbuf) != parent_info->device || _g_stat_ino (&statbuf) == parent_info->inode)) - _g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_UNIX_IS_MOUNTPOINT, TRUE); + _g_file_attribute_matcher_matches_id (attribute_matcher, G_FILE_ATTRIBUTE_ID_UNIX_IS_MOUNTPOINT)) + _g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_UNIX_IS_MOUNTPOINT, + (_g_stat_dev (&statbuf) != parent_info->device || _g_stat_ino (&statbuf) == parent_info->inode)); if (stat_ok) get_access_rights (attribute_matcher, info, path, &statbuf, parent_info); From a4e597520a46cbd158c59487e116e603691aaff4 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 6 Mar 2023 14:38:22 +0000 Subject: [PATCH 2/3] glocalfileinfo: Set is-backup attribute on Windows Previously it was only being set on non-Windows platforms. For consistency, always set it on Windows too. Signed-off-by: Philip Withnall Helps: #2934 --- gio/glocalfileinfo.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c index 6bc2d4199..dacb93289 100644 --- a/gio/glocalfileinfo.c +++ b/gio/glocalfileinfo.c @@ -2053,6 +2053,8 @@ _g_local_file_info_get (const char *basename, (stat_ok && S_ISREG (_g_stat_mode (&statbuf)))) _g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_STANDARD_IS_BACKUP, TRUE); #else + _g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_STANDARD_IS_BACKUP, FALSE); + g_file_info_set_is_hidden (info, (statbuf.attributes & FILE_ATTRIBUTE_HIDDEN)); _g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_DOS_IS_ARCHIVE, From 303d79989cfd2c4ee265380d3f0ec3731f6a63e2 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 6 Mar 2023 14:38:58 +0000 Subject: [PATCH 3/3] gresourcefile: Fix a missing newline in GResourceFile This introduces no functional changes. Signed-off-by: Philip Withnall --- gio/gresourcefile.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gio/gresourcefile.c b/gio/gresourcefile.c index 24f20f290..488fa34e2 100644 --- a/gio/gresourcefile.c +++ b/gio/gresourcefile.c @@ -558,7 +558,8 @@ g_resource_file_query_filesystem_info (GFile *file, if (g_file_attribute_matcher_matches (matcher, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE)) g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, "resource"); - if (g_file_attribute_matcher_matches (matcher, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY)) g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, TRUE); + if (g_file_attribute_matcher_matches (matcher, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY)) + g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, TRUE); g_file_attribute_matcher_unref (matcher);