summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Cisler <pavel@eazel.com>2000-12-29 07:37:19 +0000
committerPavel Cisler <pce@src.gnome.org>2000-12-29 07:37:19 +0000
commitf9641febb24a16d3e3da77bceb8ef068a557d1d1 (patch)
treec8d78c05a900b46c330711b734baa55c63f0c1d6
parent27287ebbbfb67c9451711bfa76574e6b3b79052f (diff)
downloadnautilus-f9641febb24a16d3e3da77bceb8ef068a557d1d1.tar.gz
Fixed bug 4952 (Move or copy or large number of items fails). Final part
2000-12-28 Pavel Cisler <pavel@eazel.com> Fixed bug 4952 (Move or copy or large number of items fails). Final part of fix for bug 956 (UI takes time to become operational after drag&drop) * libnautilus-extensions/nautilus-file-changes-queue.c: (nautilus_file_changes_consume_changes): Fixed a bug in the logic that chunked up file change notifications into groups that could be all handled at once - before the fix each change was processed individually. Grouped move, metadata move, position setting and copy, metadata copy, position setting respectively into groups that would get all processed in a single chunk. Tweaked the maximum size of a changes chunk. * libnautilus-extensions/nautilus-file-changes-queue.c: (nautilus_file_changes_queue_schedule_metadata_copy), (nautilus_file_changes_queue_schedule_metadata_move), (nautilus_file_changes_queue_schedule_metadata_remove), (nautilus_file_changes_queue_schedule_position_setting): Some renamings. * libnautilus-extensions/nautilus-directory-async.c: Small tweak to make turning on debugging diagnostics easier.
-rw-r--r--ChangeLog25
-rw-r--r--libnautilus-extensions/nautilus-directory-async.c10
-rw-r--r--libnautilus-extensions/nautilus-file-changes-queue.c93
-rw-r--r--libnautilus-private/nautilus-directory-async.c10
-rw-r--r--libnautilus-private/nautilus-file-changes-queue.c93
5 files changed, 159 insertions, 72 deletions
diff --git a/ChangeLog b/ChangeLog
index a3926d7d5..b602ee1f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2000-12-28 Pavel Cisler <pavel@eazel.com>
+
+ Fixed bug 4952 (Move or copy or large number of items fails).
+ Final part of fix for bug 956 (UI takes time to become operational
+ after drag&drop)
+
+ * libnautilus-extensions/nautilus-file-changes-queue.c:
+ (nautilus_file_changes_consume_changes): Fixed a bug in
+ the logic that chunked up file change notifications into groups
+ that could be all handled at once - before the fix each change
+ was processed individually. Grouped move, metadata move, position
+ setting and copy, metadata copy, position setting respectively
+ into groups that would get all processed in a single chunk.
+ Tweaked the maximum size of a changes chunk.
+
+ * libnautilus-extensions/nautilus-file-changes-queue.c:
+ (nautilus_file_changes_queue_schedule_metadata_copy),
+ (nautilus_file_changes_queue_schedule_metadata_move),
+ (nautilus_file_changes_queue_schedule_metadata_remove),
+ (nautilus_file_changes_queue_schedule_position_setting):
+ Some renamings.
+
+ * libnautilus-extensions/nautilus-directory-async.c:
+ Small tweak to make turning on debugging diagnostics easier.
+
2000-12-28 Mike Fleming <mfleming@eazel.com>
* components/services/summary/nautilus-view/main.c: (main):
diff --git a/libnautilus-extensions/nautilus-directory-async.c b/libnautilus-extensions/nautilus-directory-async.c
index 6b7ce0b0a..4844160cb 100644
--- a/libnautilus-extensions/nautilus-directory-async.c
+++ b/libnautilus-extensions/nautilus-directory-async.c
@@ -41,13 +41,15 @@
#include <stdlib.h>
#include <stdio.h>
-/* comment this back in to see messages about each load_directory call:
+#if 0
+/* comment this back in to see messages about each load_directory call: */
#define DEBUG_LOAD_DIRECTORY
-*/
+#endif
-/* comment this back in to check if async. job calls are balanced
+#if 0
+/* comment this back in to check if async. job calls are balanced */
#define DEBUG_ASYNC_JOBS
-*/
+#endif
#define METAFILE_PERMISSIONS (GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_USER_WRITE \
| GNOME_VFS_PERM_GROUP_READ | GNOME_VFS_PERM_GROUP_WRITE \
diff --git a/libnautilus-extensions/nautilus-file-changes-queue.c b/libnautilus-extensions/nautilus-file-changes-queue.c
index 3919bf54e..def67f421 100644
--- a/libnautilus-extensions/nautilus-file-changes-queue.c
+++ b/libnautilus-extensions/nautilus-file-changes-queue.c
@@ -41,10 +41,10 @@ typedef enum {
CHANGE_FILE_ADDED,
CHANGE_FILE_REMOVED,
CHANGE_FILE_MOVED,
- CHANGE_METADATA_COPY,
- CHANGE_METADATA_MOVE,
- CHANGE_METADATA_REMOVE,
- CHANGE_POSITION_SETTING
+ CHANGE_METADATA_COPIED,
+ CHANGE_METADATA_MOVED,
+ CHANGE_METADATA_REMOVED,
+ CHANGE_POSITION_SET
} NautilusFileChangeKind;
typedef struct {
@@ -190,7 +190,7 @@ nautilus_file_changes_queue_schedule_metadata_copy (const char *from_uri,
queue = nautilus_file_changes_queue_get ();
new_item = g_new (NautilusFileChange, 1);
- new_item->kind = CHANGE_METADATA_COPY;
+ new_item->kind = CHANGE_METADATA_COPIED;
new_item->from_uri = g_strdup (from_uri);
new_item->to_uri = g_strdup (to_uri);
nautilus_file_changes_queue_add_common (queue, new_item);
@@ -206,7 +206,7 @@ nautilus_file_changes_queue_schedule_metadata_move (const char *from_uri,
queue = nautilus_file_changes_queue_get ();
new_item = g_new (NautilusFileChange, 1);
- new_item->kind = CHANGE_METADATA_MOVE;
+ new_item->kind = CHANGE_METADATA_MOVED;
new_item->from_uri = g_strdup (from_uri);
new_item->to_uri = g_strdup (to_uri);
nautilus_file_changes_queue_add_common (queue, new_item);
@@ -221,7 +221,7 @@ nautilus_file_changes_queue_schedule_metadata_remove (const char *uri)
queue = nautilus_file_changes_queue_get ();
new_item = g_new (NautilusFileChange, 1);
- new_item->kind = CHANGE_METADATA_REMOVE;
+ new_item->kind = CHANGE_METADATA_REMOVED;
new_item->from_uri = g_strdup (uri);
nautilus_file_changes_queue_add_common (queue, new_item);
}
@@ -236,7 +236,7 @@ nautilus_file_changes_queue_schedule_position_setting (const char *uri,
queue = nautilus_file_changes_queue_get ();
new_item = g_new (NautilusFileChange, 1);
- new_item->kind = CHANGE_POSITION_SETTING;
+ new_item->kind = CHANGE_POSITION_SET;
new_item->from_uri = g_strdup (uri);
new_item->point = point;
nautilus_file_changes_queue_add_common (queue, new_item);
@@ -270,7 +270,7 @@ nautilus_file_changes_queue_get_change (NautilusFileChangesQueue *queue)
}
enum {
- CONSUME_CHANGES_MAX_CHUNK = 10
+ CONSUME_CHANGES_MAX_CHUNK = 20
};
static void
@@ -318,9 +318,9 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
GList *position_setting_requests;
URIPair *pair;
NautilusFileChangesQueuePositionSetting *position_setting;
- NautilusFileChangeKind kind;
guint chunk_count;
NautilusFileChangesQueue *queue;
+ gboolean flush_needed;
additions = NULL;
@@ -330,7 +330,6 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
metadata_move_requests = NULL;
metadata_remove_requests = NULL;
position_setting_requests = NULL;
- kind = CHANGE_FILE_INITIAL;
queue = nautilus_file_changes_queue_get();
@@ -342,23 +341,56 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
for (chunk_count = 0; ; chunk_count++) {
change = nautilus_file_changes_queue_get_change (queue);
- if (change == NULL
- /* no changes left */
- || change->kind != kind
- /* all the changes we have are different that the new one */
- || (!consume_all && chunk_count >= CONSUME_CHANGES_MAX_CHUNK)) {
- /* we have reached the chunk maximum */
+ /* figure out if we need to flush the pending changes that we collected sofar */
+ if (change == NULL) {
+ flush_needed = TRUE;
+ /* no changes left, flush everything */
+ } else {
+ flush_needed = (additions != NULL
+ && (change->kind != CHANGE_FILE_ADDED
+ && change->kind != CHANGE_METADATA_COPIED
+ && change->kind != CHANGE_POSITION_SET));
+
+ flush_needed |= (moves != NULL
+ && (change->kind != CHANGE_FILE_MOVED
+ && change->kind != CHANGE_METADATA_MOVED
+ && change->kind != CHANGE_POSITION_SET));
+
+ flush_needed |= (deletions != NULL
+ && (change->kind != CHANGE_FILE_REMOVED
+ && change->kind != CHANGE_METADATA_REMOVED));
+
+ flush_needed |= (metadata_copy_requests != NULL
+ && (change->kind != CHANGE_FILE_ADDED
+ && change->kind != CHANGE_METADATA_COPIED
+ && change->kind != CHANGE_POSITION_SET));
+
+ flush_needed |= (metadata_move_requests != NULL
+ && (change->kind != CHANGE_FILE_MOVED
+ && change->kind != CHANGE_METADATA_MOVED
+ && change->kind != CHANGE_POSITION_SET));
+
+ flush_needed |= (metadata_remove_requests != NULL
+ && (change->kind != CHANGE_FILE_REMOVED
+ && change->kind != CHANGE_METADATA_REMOVED));
+
+ flush_needed |= (position_setting_requests != NULL
+ && (change->kind != CHANGE_POSITION_SET
+ && change->kind != CHANGE_FILE_ADDED
+ && change->kind != CHANGE_FILE_MOVED
+ && change->kind != CHANGE_METADATA_COPIED
+ && change->kind != CHANGE_METADATA_MOVED));
+
+ flush_needed |= !consume_all && chunk_count >= CONSUME_CHANGES_MAX_CHUNK;
+ /* we have reached the chunk maximum */
+ }
+
+ if (flush_needed) {
/* Send changes we collected off.
- * At one time we may only have one of the three lists
+ * At one time we may only have one of the lists
* contain changes.
*/
-
- g_assert ((deletions != NULL) + (moves != NULL)
- + (additions != NULL) + (metadata_copy_requests != NULL)
- + (metadata_move_requests != NULL)
- + (metadata_remove_requests != NULL)
- + (position_setting_requests != NULL) <= 1);
if (deletions != NULL) {
nautilus_directory_notify_files_removed (deletions);
@@ -402,10 +434,8 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
return;
}
- kind = change->kind;
-
/* add the new change to the list */
- switch (kind) {
+ switch (change->kind) {
case CHANGE_FILE_ADDED:
additions = g_list_append (additions, change->from_uri);
break;
@@ -421,26 +451,26 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
moves = g_list_append (moves, pair);
break;
- case CHANGE_METADATA_COPY:
+ case CHANGE_METADATA_COPIED:
pair = g_new (URIPair, 1);
pair->from_uri = change->from_uri;
pair->to_uri = change->to_uri;
metadata_copy_requests = g_list_append (metadata_copy_requests, pair);
break;
- case CHANGE_METADATA_MOVE:
+ case CHANGE_METADATA_MOVED:
pair = g_new (URIPair, 1);
pair->from_uri = change->from_uri;
pair->to_uri = change->to_uri;
metadata_move_requests = g_list_append (metadata_move_requests, pair);
break;
- case CHANGE_METADATA_REMOVE:
+ case CHANGE_METADATA_REMOVED:
metadata_remove_requests = g_list_append (metadata_remove_requests,
change->from_uri);
break;
- case CHANGE_POSITION_SETTING:
+ case CHANGE_POSITION_SET:
position_setting = g_new (NautilusFileChangesQueuePositionSetting, 1);
position_setting->uri = change->from_uri;
position_setting->point = change->point;
@@ -455,5 +485,4 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
change->from_uri = NULL;
change->to_uri = NULL;
}
-
}
diff --git a/libnautilus-private/nautilus-directory-async.c b/libnautilus-private/nautilus-directory-async.c
index 6b7ce0b0a..4844160cb 100644
--- a/libnautilus-private/nautilus-directory-async.c
+++ b/libnautilus-private/nautilus-directory-async.c
@@ -41,13 +41,15 @@
#include <stdlib.h>
#include <stdio.h>
-/* comment this back in to see messages about each load_directory call:
+#if 0
+/* comment this back in to see messages about each load_directory call: */
#define DEBUG_LOAD_DIRECTORY
-*/
+#endif
-/* comment this back in to check if async. job calls are balanced
+#if 0
+/* comment this back in to check if async. job calls are balanced */
#define DEBUG_ASYNC_JOBS
-*/
+#endif
#define METAFILE_PERMISSIONS (GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_USER_WRITE \
| GNOME_VFS_PERM_GROUP_READ | GNOME_VFS_PERM_GROUP_WRITE \
diff --git a/libnautilus-private/nautilus-file-changes-queue.c b/libnautilus-private/nautilus-file-changes-queue.c
index 3919bf54e..def67f421 100644
--- a/libnautilus-private/nautilus-file-changes-queue.c
+++ b/libnautilus-private/nautilus-file-changes-queue.c
@@ -41,10 +41,10 @@ typedef enum {
CHANGE_FILE_ADDED,
CHANGE_FILE_REMOVED,
CHANGE_FILE_MOVED,
- CHANGE_METADATA_COPY,
- CHANGE_METADATA_MOVE,
- CHANGE_METADATA_REMOVE,
- CHANGE_POSITION_SETTING
+ CHANGE_METADATA_COPIED,
+ CHANGE_METADATA_MOVED,
+ CHANGE_METADATA_REMOVED,
+ CHANGE_POSITION_SET
} NautilusFileChangeKind;
typedef struct {
@@ -190,7 +190,7 @@ nautilus_file_changes_queue_schedule_metadata_copy (const char *from_uri,
queue = nautilus_file_changes_queue_get ();
new_item = g_new (NautilusFileChange, 1);
- new_item->kind = CHANGE_METADATA_COPY;
+ new_item->kind = CHANGE_METADATA_COPIED;
new_item->from_uri = g_strdup (from_uri);
new_item->to_uri = g_strdup (to_uri);
nautilus_file_changes_queue_add_common (queue, new_item);
@@ -206,7 +206,7 @@ nautilus_file_changes_queue_schedule_metadata_move (const char *from_uri,
queue = nautilus_file_changes_queue_get ();
new_item = g_new (NautilusFileChange, 1);
- new_item->kind = CHANGE_METADATA_MOVE;
+ new_item->kind = CHANGE_METADATA_MOVED;
new_item->from_uri = g_strdup (from_uri);
new_item->to_uri = g_strdup (to_uri);
nautilus_file_changes_queue_add_common (queue, new_item);
@@ -221,7 +221,7 @@ nautilus_file_changes_queue_schedule_metadata_remove (const char *uri)
queue = nautilus_file_changes_queue_get ();
new_item = g_new (NautilusFileChange, 1);
- new_item->kind = CHANGE_METADATA_REMOVE;
+ new_item->kind = CHANGE_METADATA_REMOVED;
new_item->from_uri = g_strdup (uri);
nautilus_file_changes_queue_add_common (queue, new_item);
}
@@ -236,7 +236,7 @@ nautilus_file_changes_queue_schedule_position_setting (const char *uri,
queue = nautilus_file_changes_queue_get ();
new_item = g_new (NautilusFileChange, 1);
- new_item->kind = CHANGE_POSITION_SETTING;
+ new_item->kind = CHANGE_POSITION_SET;
new_item->from_uri = g_strdup (uri);
new_item->point = point;
nautilus_file_changes_queue_add_common (queue, new_item);
@@ -270,7 +270,7 @@ nautilus_file_changes_queue_get_change (NautilusFileChangesQueue *queue)
}
enum {
- CONSUME_CHANGES_MAX_CHUNK = 10
+ CONSUME_CHANGES_MAX_CHUNK = 20
};
static void
@@ -318,9 +318,9 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
GList *position_setting_requests;
URIPair *pair;
NautilusFileChangesQueuePositionSetting *position_setting;
- NautilusFileChangeKind kind;
guint chunk_count;
NautilusFileChangesQueue *queue;
+ gboolean flush_needed;
additions = NULL;
@@ -330,7 +330,6 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
metadata_move_requests = NULL;
metadata_remove_requests = NULL;
position_setting_requests = NULL;
- kind = CHANGE_FILE_INITIAL;
queue = nautilus_file_changes_queue_get();
@@ -342,23 +341,56 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
for (chunk_count = 0; ; chunk_count++) {
change = nautilus_file_changes_queue_get_change (queue);
- if (change == NULL
- /* no changes left */
- || change->kind != kind
- /* all the changes we have are different that the new one */
- || (!consume_all && chunk_count >= CONSUME_CHANGES_MAX_CHUNK)) {
- /* we have reached the chunk maximum */
+ /* figure out if we need to flush the pending changes that we collected sofar */
+ if (change == NULL) {
+ flush_needed = TRUE;
+ /* no changes left, flush everything */
+ } else {
+ flush_needed = (additions != NULL
+ && (change->kind != CHANGE_FILE_ADDED
+ && change->kind != CHANGE_METADATA_COPIED
+ && change->kind != CHANGE_POSITION_SET));
+
+ flush_needed |= (moves != NULL
+ && (change->kind != CHANGE_FILE_MOVED
+ && change->kind != CHANGE_METADATA_MOVED
+ && change->kind != CHANGE_POSITION_SET));
+
+ flush_needed |= (deletions != NULL
+ && (change->kind != CHANGE_FILE_REMOVED
+ && change->kind != CHANGE_METADATA_REMOVED));
+
+ flush_needed |= (metadata_copy_requests != NULL
+ && (change->kind != CHANGE_FILE_ADDED
+ && change->kind != CHANGE_METADATA_COPIED
+ && change->kind != CHANGE_POSITION_SET));
+
+ flush_needed |= (metadata_move_requests != NULL
+ && (change->kind != CHANGE_FILE_MOVED
+ && change->kind != CHANGE_METADATA_MOVED
+ && change->kind != CHANGE_POSITION_SET));
+
+ flush_needed |= (metadata_remove_requests != NULL
+ && (change->kind != CHANGE_FILE_REMOVED
+ && change->kind != CHANGE_METADATA_REMOVED));
+
+ flush_needed |= (position_setting_requests != NULL
+ && (change->kind != CHANGE_POSITION_SET
+ && change->kind != CHANGE_FILE_ADDED
+ && change->kind != CHANGE_FILE_MOVED
+ && change->kind != CHANGE_METADATA_COPIED
+ && change->kind != CHANGE_METADATA_MOVED));
+
+ flush_needed |= !consume_all && chunk_count >= CONSUME_CHANGES_MAX_CHUNK;
+ /* we have reached the chunk maximum */
+ }
+
+ if (flush_needed) {
/* Send changes we collected off.
- * At one time we may only have one of the three lists
+ * At one time we may only have one of the lists
* contain changes.
*/
-
- g_assert ((deletions != NULL) + (moves != NULL)
- + (additions != NULL) + (metadata_copy_requests != NULL)
- + (metadata_move_requests != NULL)
- + (metadata_remove_requests != NULL)
- + (position_setting_requests != NULL) <= 1);
if (deletions != NULL) {
nautilus_directory_notify_files_removed (deletions);
@@ -402,10 +434,8 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
return;
}
- kind = change->kind;
-
/* add the new change to the list */
- switch (kind) {
+ switch (change->kind) {
case CHANGE_FILE_ADDED:
additions = g_list_append (additions, change->from_uri);
break;
@@ -421,26 +451,26 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
moves = g_list_append (moves, pair);
break;
- case CHANGE_METADATA_COPY:
+ case CHANGE_METADATA_COPIED:
pair = g_new (URIPair, 1);
pair->from_uri = change->from_uri;
pair->to_uri = change->to_uri;
metadata_copy_requests = g_list_append (metadata_copy_requests, pair);
break;
- case CHANGE_METADATA_MOVE:
+ case CHANGE_METADATA_MOVED:
pair = g_new (URIPair, 1);
pair->from_uri = change->from_uri;
pair->to_uri = change->to_uri;
metadata_move_requests = g_list_append (metadata_move_requests, pair);
break;
- case CHANGE_METADATA_REMOVE:
+ case CHANGE_METADATA_REMOVED:
metadata_remove_requests = g_list_append (metadata_remove_requests,
change->from_uri);
break;
- case CHANGE_POSITION_SETTING:
+ case CHANGE_POSITION_SET:
position_setting = g_new (NautilusFileChangesQueuePositionSetting, 1);
position_setting->uri = change->from_uri;
position_setting->point = change->point;
@@ -455,5 +485,4 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
change->from_uri = NULL;
change->to_uri = NULL;
}
-
}