[PATCH] Fix trash deep count



From bug 46200 [1]:

'
(1) Launch Nautilus
(2) Right-click trash icon on desktop and choose "Show Properties"

Note that by "Contents" it says "--"
'

Proposed patch attached.

[1] http://bugzilla.gnome.org/show_bug.cgi?id=46200

-- 
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-trash-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-trash-file.c,v
retrieving revision 1.22
diff -u -p -r1.22 nautilus-trash-file.c
--- libnautilus-private/nautilus-trash-file.c	2 Apr 2003 11:51:00 -0000	1.22
+++ libnautilus-private/nautilus-trash-file.c	30 Jul 2005 09:30:05 -0000
@@ -79,6 +79,7 @@ static NautilusFileAttributes 
 get_delegated_attributes_mask (void)
 {
 	return NAUTILUS_FILE_ATTRIBUTE_DEEP_COUNTS |
+		NAUTILUS_FILE_ATTRIBUTE_FILE_TYPE |
 		NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT |
 		NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES;
 }
@@ -589,6 +590,13 @@ trash_file_get_item_count (NautilusFile 
 	return got_count;
 }
 
+static void
+file_type_is_ready (NautilusFile *file,
+		    gpointer trash_file)
+{
+	nautilus_file_updated_deep_count_in_progress (trash_file);
+}
+
 static NautilusRequestStatus
 trash_file_get_deep_counts (NautilusFile *file,
 			    guint *directory_count,
@@ -600,6 +608,7 @@ trash_file_get_deep_counts (NautilusFile
 	GList *node;
 	NautilusRequestStatus status, one_status;
 	guint one_directory_count, one_file_count, one_unreadable_directory_count;
+	gboolean any_file_was_ready, all_files_were_ready;
 	GnomeVFSFileSize one_total_size;
 
 	trash = NAUTILUS_TRASH_FILE (file);
@@ -618,7 +627,20 @@ trash_file_get_deep_counts (NautilusFile
 		*total_size = 0;
 	}
 
+	any_file_was_ready = FALSE;
+	all_files_were_ready = TRUE;
 	for (node = trash->details->files; node != NULL; node = node->next) {
+		if (!nautilus_file_check_if_ready (node->data, NAUTILUS_FILE_ATTRIBUTE_FILE_TYPE)) {
+			/* nautilus-directory-asnync.c:deep_count_start will fail if node->data is not
+			 * yet recognized as directory */
+			all_files_were_ready = FALSE;
+			nautilus_file_call_when_ready (node->data, NAUTILUS_FILE_ATTRIBUTE_FILE_TYPE,
+						       file_type_is_ready, trash);
+			continue;
+		}
+
+		any_file_was_ready = TRUE;
+
 		one_status = nautilus_file_get_deep_counts
 			(node->data,
 			 &one_directory_count,
@@ -641,6 +663,12 @@ trash_file_get_deep_counts (NautilusFile
 		if (total_size != NULL) {
 			*total_size += one_total_size;
 		}
+	}
+
+	if (!any_file_was_ready) {
+		status = NAUTILUS_REQUEST_NOT_STARTED;
+	} else if (!all_files_were_ready) {
+		status = NAUTILUS_REQUEST_IN_PROGRESS;
 	}
 
 	return status;

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]