[gnome-settings-daemon/gnome-3-8] housekeeping: Don't follow symlinks to subdirectories
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/gnome-3-8] housekeeping: Don't follow symlinks to subdirectories
- Date: Mon, 19 May 2014 15:04:54 +0000 (UTC)
commit 138134ea54667cb20da20f65ab1f02146732cfc7
Author: Bastien Nocera <hadess hadess net>
Date: Mon May 19 12:58:07 2014 +0200
housekeeping: Don't follow symlinks to subdirectories
Check whether a leaf node is a symlink before processing it, and if it
is, check whether we should delete the link itself.
This works around a possible bug in GIO where GFileEnumerators will get
the filetype of the linked-to item, instead of detecting that it is a
symlink.
https://bugzilla.gnome.org/show_bug.cgi?id=730223
plugins/housekeeping/gsd-disk-space.c | 53 ++++++++++++++++++++++++++++-----
1 files changed, 45 insertions(+), 8 deletions(-)
---
diff --git a/plugins/housekeeping/gsd-disk-space.c b/plugins/housekeeping/gsd-disk-space.c
index a03b734..e661cfd 100644
--- a/plugins/housekeeping/gsd-disk-space.c
+++ b/plugins/housekeeping/gsd-disk-space.c
@@ -416,6 +416,44 @@ delete_subdir (GObject *source,
delete_data_unref (data);
}
+static void
+delete_subdir_check_symlink (GObject *source,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GFile *file = G_FILE (source);
+ DeleteData *data = user_data;
+ GFileInfo *info;
+ GFileType type;
+
+ info = g_file_query_info_finish (file, res, NULL);
+ if (!info) {
+ delete_data_unref (data);
+ return;
+ }
+
+ type = g_file_info_get_file_type (info);
+ g_object_unref (info);
+
+ if (type == G_FILE_TYPE_DIRECTORY) {
+ g_file_enumerate_children_async (data->file,
+ G_FILE_ATTRIBUTE_STANDARD_NAME ","
+ G_FILE_ATTRIBUTE_STANDARD_TYPE,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ 0,
+ data->cancellable,
+ delete_subdir,
+ delete_data_ref (data));
+ } else if (type == G_FILE_TYPE_SYMBOLIC_LINK) {
+ if (should_purge_file (data->file, data->cancellable, data->old)) {
+ if (!data->dry_run) {
+ g_file_delete (data->file, data->cancellable, NULL);
+ }
+ }
+ }
+ delete_data_unref (data);
+}
+
void
delete_recursively_by_age (DeleteData *data)
{
@@ -425,14 +463,13 @@ delete_recursively_by_age (DeleteData *data)
return;
}
- g_file_enumerate_children_async (data->file,
- G_FILE_ATTRIBUTE_STANDARD_NAME ","
- G_FILE_ATTRIBUTE_STANDARD_TYPE,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- 0,
- data->cancellable,
- delete_subdir,
- delete_data_ref (data));
+ g_file_query_info_async (data->file,
+ G_FILE_ATTRIBUTE_STANDARD_TYPE,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ 0,
+ data->cancellable,
+ delete_subdir_check_symlink,
+ delete_data_ref (data));
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]