nautilus r14190 - in branches/gnome-2-22: . libnautilus-private



Author: cneumair
Date: Fri May 23 17:38:40 2008
New Revision: 14190
URL: http://svn.gnome.org/viewvc/nautilus?rev=14190&view=rev

Log:
2008-05-23  Christian Neumair  <cneumair gnome org>

	* libnautilus-private/nautilus-directory-async.c (seen_inode),
	(mark_inode_as_seen), (deep_count_one), (deep_count_state_free),
	(deep_count_load), (deep_count_start):
	Do not count the same inode twice when calculating size. Fixes
	#313668.


Modified:
   branches/gnome-2-22/ChangeLog
   branches/gnome-2-22/libnautilus-private/nautilus-directory-async.c

Modified: branches/gnome-2-22/libnautilus-private/nautilus-directory-async.c
==============================================================================
--- branches/gnome-2-22/libnautilus-private/nautilus-directory-async.c	(original)
+++ branches/gnome-2-22/libnautilus-private/nautilus-directory-async.c	Fri May 23 17:38:40 2008
@@ -137,6 +137,7 @@
 	GFileEnumerator *enumerator;
 	GFile *deep_count_location;
 	GList *deep_count_subdirectories;
+	GArray *seen_deep_count_inodes;
 };
 
 
@@ -2662,17 +2663,56 @@
 	g_object_unref (location);
 }
 
+static inline gboolean
+seen_inode (DeepCountState *state,
+	    GFileInfo *info)
+{
+	guint64 inode, inode2;
+	guint i;
+
+	inode = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_UNIX_INODE);
+
+	if (inode != 0) {
+		for (i = 0; i < state->seen_deep_count_inodes->len; i++) {
+			inode2 = g_array_index (state->seen_deep_count_inodes, guint64, i);
+			if (inode == inode2) {
+				return TRUE;
+			}
+		}
+	}
+
+	return FALSE;
+}
+
+static inline void
+mark_inode_as_seen (DeepCountState *state,
+		    GFileInfo *info)
+{
+	guint64 inode;
+
+	inode = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_UNIX_INODE);
+	if (inode != 0) {
+		g_array_append_val (state->seen_deep_count_inodes, inode);
+	}
+}
+
 static void
 deep_count_one (DeepCountState *state,
 		GFileInfo *info)
 {
 	NautilusFile *file;
 	GFile *subdir;
+	gboolean is_seen_inode;
 
 	if (should_skip_file (NULL, info)) {
 		return;
 	}
 
+	is_seen_inode = seen_inode (state, info);
+	if (!is_seen_inode) {
+		mark_inode_as_seen (state, info);
+	}
+
 	file = state->directory->details->deep_count_file;
 
 	if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
@@ -2690,7 +2730,7 @@
 	}
 
 	/* Count the size. */
-	if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_SIZE)) {
+	if (!is_seen_inode && g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_SIZE)) {
 		file->details->deep_size += g_file_info_get_size (info);
 	}
 }
@@ -2710,6 +2750,7 @@
 		g_object_unref (state->deep_count_location);
 	}
 	eel_g_object_list_free (state->deep_count_subdirectories);
+	g_array_free (state->seen_deep_count_inodes, TRUE);
 	g_free (state);
 }
 
@@ -2858,7 +2899,8 @@
 					 G_FILE_ATTRIBUTE_STANDARD_TYPE ","
 					 G_FILE_ATTRIBUTE_STANDARD_SIZE ","
 					 G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN ","
-					 G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP,
+					 G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP ","
+					 G_FILE_ATTRIBUTE_UNIX_INODE,
 					 G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, /* flags */
 					 G_PRIORITY_LOW, /* prio */
 					 state->cancellable,
@@ -2930,6 +2972,7 @@
 	state = g_new0 (DeepCountState, 1);
 	state->directory = directory;
 	state->cancellable = g_cancellable_new ();
+	state->seen_deep_count_inodes = g_array_new (FALSE, TRUE, sizeof (guint64));
 
 	directory->details->deep_count_in_progress = state;
 	



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