summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Schulman <rebecka@eazel.com>2000-10-20 23:53:07 +0000
committerRebecca Schulman <rebecka@src.gnome.org>2000-10-20 23:53:07 +0000
commit0c65eaca24bbd687c10505a8a1a13718e2e10c56 (patch)
treeac9d870a18b95a657dca2876edec9e739482c60c
parent560bc56743c03a4f3fac5c3d44440f4f9f7ab3b6 (diff)
downloadnautilus-0c65eaca24bbd687c10505a8a1a13718e2e10c56.tar.gz
Fix for bug 1768, to put a hard limit on the number of files for PR2. We
2000-10-20 Rebecca Schulman <rebecka@eazel.com> Fix for bug 1768, to put a hard limit on the number of files for PR2. We do this by keeping a count of confirmed files in directories, and stopping a load once the confirmed file count reaches a certain level. * libnautilus-extensions/nautilus-directory-async.c: (set_file_unconfirmed), (dequeue_pending_idle_callback), (directory_load_one), (directory_load_done), (directory_load_callback), (mark_all_files_unconfirmed), (nautilus_directory_stop_monitoring_file_list): Increment or decrement file count when marking a file confirmed or unconfirmed. * libnautilus-extensions/nautilus-directory-private.h: add file count file * libnautilus-extensions/nautilus-directory.c: (nautilus_directory_add_file), (nautilus_directory_remove_file), (nautilus_directory_file_list_length_reached): increment and decrement file counts here when a file is added. A file is always confirmed when it is initially added, so increment always, but only decrement the count when we are removing a confirmed file. * libnautilus-extensions/nautilus-directory.h: Add function nautilus_directory_file_list_length_reached as public * src/file-manager/fm-directory-view.c: (check_for_directory_hard_limit), (done_loading): when we finish loading the directory, display the hard limit dialog if necesssary, to let the user know we've stopped the directory load to prevent nautilus from overloading. 2000-10-20 Rebecca Schulman <rebecka@eazel.com> Fix for bug 1768, to put a hard limit on the number of files for PR2. We do this by keeping a count of confirmed files in directories, and stopping a load once the confirmed file count reaches a certain level. * libnautilus-extensions/nautilus-directory-async.c: (set_file_unconfirmed), (dequeue_pending_idle_callback), (directory_load_one), (directory_load_done), (directory_load_callback), (mark_all_files_unconfirmed), (nautilus_directory_stop_monitoring_file_list): Increment or decrement file count when marking a file confirmed or unconfirmed. * libnautilus-extensions/nautilus-directory-private.h: add file count file * libnautilus-extensions/nautilus-directory.c: (nautilus_directory_add_file), (nautilus_directory_remove_file), (nautilus_directory_file_list_length_reached): increment and decrement file counts here when a file is added. A file is always confirmed when it is initially added, so increment always, but only decrement the count when we are removing a confirmed file. * libnautilus-extensions/nautilus-directory.h: Add function nautilus_directory_file_list_length_reached as public * src/file-manager/fm-directory-view.c: (check_for_directory_hard_limit), (done_loading): when we finish loading the directory, display the hard limit dialog if necesssary, to let the user know we've stopped the directory load to prevent nautilus from overloading.
-rw-r--r--ChangeLog32
-rw-r--r--libnautilus-extensions/nautilus-directory-async.c37
-rw-r--r--libnautilus-extensions/nautilus-directory-private.h1
-rw-r--r--libnautilus-extensions/nautilus-directory.c16
-rw-r--r--libnautilus-extensions/nautilus-directory.h2
-rw-r--r--libnautilus-private/nautilus-directory-async.c37
-rw-r--r--libnautilus-private/nautilus-directory-private.h1
-rw-r--r--libnautilus-private/nautilus-directory.c16
-rw-r--r--libnautilus-private/nautilus-directory.h2
-rw-r--r--src/file-manager/fm-directory-view.c22
10 files changed, 150 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index aa2f4a6b9..189f898ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2000-10-20 Rebecca Schulman <rebecka@eazel.com>
+ Fix for bug 1768, to put a hard limit on
+ the number of files for PR2. We do this
+ by keeping a count of confirmed files
+ in directories, and stopping a load once the confirmed
+ file count reaches a certain level.
+
+ * libnautilus-extensions/nautilus-directory-async.c:
+ (set_file_unconfirmed), (dequeue_pending_idle_callback),
+ (directory_load_one), (directory_load_done),
+ (directory_load_callback), (mark_all_files_unconfirmed),
+ (nautilus_directory_stop_monitoring_file_list):
+ Increment or decrement file count when marking a file confirmed
+ or unconfirmed.
+ * libnautilus-extensions/nautilus-directory-private.h:
+ add file count file
+ * libnautilus-extensions/nautilus-directory.c:
+ (nautilus_directory_add_file), (nautilus_directory_remove_file),
+ (nautilus_directory_file_list_length_reached):
+ increment and decrement file counts here when a file is added.
+ A file is always confirmed when it is initially added, so
+ increment always, but only decrement the count when we are
+ removing a confirmed file.
+ * libnautilus-extensions/nautilus-directory.h:
+ Add function nautilus_directory_file_list_length_reached
+ as public
+ * src/file-manager/fm-directory-view.c:
+ (check_for_directory_hard_limit), (done_loading):
+ when we finish loading the directory, display the hard limit
+ dialog if necesssary, to let the user know we've stopped the directory
+ load to prevent nautilus from overloading.
+
2000-10-20 Darin Adler <darin@eazel.com>
* components/loser/content/Makefile.am:
diff --git a/libnautilus-extensions/nautilus-directory-async.c b/libnautilus-extensions/nautilus-directory-async.c
index c6b402ee7..c7bdf3a40 100644
--- a/libnautilus-extensions/nautilus-directory-async.c
+++ b/libnautilus-extensions/nautilus-directory-async.c
@@ -1087,6 +1087,27 @@ update_file_info_in_list_if_needed (GList *list,
return TRUE;
}
+static void
+set_file_unconfirmed (NautilusFile *file, gboolean unconfirmed)
+{
+ NautilusDirectory *directory;
+
+ g_assert (NAUTILUS_IS_FILE (file));
+ if (file->details->unconfirmed == unconfirmed) {
+ return;
+ }
+ file->details->unconfirmed = unconfirmed;
+
+ directory = file->details->directory;
+ if (unconfirmed) {
+ directory->details->confirmed_file_count--;
+ }
+ else {
+ directory->details->confirmed_file_count++;
+ }
+}
+
+
static gboolean
dequeue_pending_idle_callback (gpointer callback_data)
{
@@ -1124,7 +1145,7 @@ dequeue_pending_idle_callback (gpointer callback_data)
file = nautilus_directory_find_file (directory, file_info->name);
if (file != NULL) {
/* file already exists, check if it changed */
- file->details->unconfirmed = FALSE;
+ set_file_unconfirmed (file, FALSE);
if (nautilus_file_update_info (file, file_info, FALSE)) {
/* File changed, notify about the change. */
nautilus_file_ref (file);
@@ -1203,7 +1224,7 @@ directory_load_one (NautilusDirectory *directory,
return;
}
gnome_vfs_file_info_ref (info);
- directory->details->pending_file_info
+ directory->details->pending_file_info
= g_list_prepend (directory->details->pending_file_info, info);
nautilus_directory_schedule_dequeue_pending (directory);
}
@@ -1236,7 +1257,7 @@ directory_load_done (NautilusDirectory *directory,
* about them to know whether they are really gone.
*/
for (node = directory->details->file_list; node != NULL; node = node->next) {
- NAUTILUS_FILE (node->data)->details->unconfirmed = FALSE;
+ set_file_unconfirmed (NAUTILUS_FILE (node->data), FALSE);
}
}
@@ -1290,8 +1311,10 @@ directory_load_callback (GnomeVFSAsyncHandle *handle,
}
directory->details->directory_load_list_last_handled = last_handled;
- if (result != GNOME_VFS_OK) {
- directory_load_done (directory, result);
+ if (nautilus_directory_file_list_length_reached (directory) ||
+ result != GNOME_VFS_OK) {
+ directory_load_done (directory,
+ result);
}
}
@@ -1888,8 +1911,7 @@ mark_all_files_unconfirmed (NautilusDirectory *directory)
for (node = directory->details->file_list; node != NULL; node = node->next) {
file = node->data;
-
- file->details->unconfirmed = TRUE;
+ set_file_unconfirmed (file, TRUE);
}
}
@@ -1948,7 +1970,6 @@ nautilus_directory_stop_monitoring_file_list (NautilusDirectory *directory)
directory->details->file_list_monitored = FALSE;
file_list_cancel (directory);
nautilus_file_list_unref (directory->details->file_list);
-
directory->details->directory_loaded = FALSE;
}
diff --git a/libnautilus-extensions/nautilus-directory-private.h b/libnautilus-extensions/nautilus-directory-private.h
index a0285931a..e8d4230f1 100644
--- a/libnautilus-extensions/nautilus-directory-private.h
+++ b/libnautilus-extensions/nautilus-directory-private.h
@@ -74,6 +74,7 @@ struct NautilusDirectoryDetails
GnomeVFSDirectoryListPosition directory_load_list_last_handled;
GList *pending_file_info; /* list of GnomeVFSFileInfo's that are pending */
+ int confirmed_file_count;
guint dequeue_pending_idle_id;
GList *get_file_infos_in_progress; /* list of GnomeVFSAsyncHandle * */
diff --git a/libnautilus-extensions/nautilus-directory.c b/libnautilus-extensions/nautilus-directory.c
index b2c544116..95ca68345 100644
--- a/libnautilus-extensions/nautilus-directory.c
+++ b/libnautilus-extensions/nautilus-directory.c
@@ -63,6 +63,9 @@ static guint signals[LAST_SIGNAL];
| GNOME_VFS_PERM_GROUP_ALL \
| GNOME_VFS_PERM_OTHER_ALL)
+/* Hack for PR2 to prevent use of too many resources */
+#define NAUTILUS_DIRECTORY_FILE_LIST_HARD_LIMIT 4000
+
static GHashTable *directories;
static void nautilus_directory_destroy (GtkObject *object);
@@ -550,6 +553,8 @@ nautilus_directory_add_file (NautilusDirectory *directory, NautilusFile *file)
/* Add to hash table. */
add_to_hash_table (directory, file, node);
+ directory->details->confirmed_file_count++;
+
/* Ref if we are monitoring. */
if (nautilus_directory_is_file_list_monitored (directory)) {
nautilus_file_ref (file);
@@ -575,12 +580,23 @@ nautilus_directory_remove_file (NautilusDirectory *directory, NautilusFile *file
(directory->details->file_list, node);
g_list_free_1 (node);
+ if (file->details->unconfirmed == FALSE) {
+ directory->details->confirmed_file_count--;
+ }
+
/* Unref if we are monitoring. */
if (nautilus_directory_is_file_list_monitored (directory)) {
nautilus_file_unref (file);
}
}
+gboolean
+nautilus_directory_file_list_length_reached (NautilusDirectory *directory)
+{
+ return directory->details->confirmed_file_count >= NAUTILUS_DIRECTORY_FILE_LIST_HARD_LIMIT;
+}
+
+
GList *
nautilus_directory_begin_file_name_change (NautilusDirectory *directory,
NautilusFile *file)
diff --git a/libnautilus-extensions/nautilus-directory.h b/libnautilus-extensions/nautilus-directory.h
index 8d895d59d..ef58b32e0 100644
--- a/libnautilus-extensions/nautilus-directory.h
+++ b/libnautilus-extensions/nautilus-directory.h
@@ -185,4 +185,6 @@ gboolean nautilus_directory_is_local (NautilusDirectory
*/
gboolean nautilus_directory_is_not_empty (NautilusDirectory *directory);
+
+gboolean nautilus_directory_file_list_length_reached (NautilusDirectory *directory);
#endif /* NAUTILUS_DIRECTORY_H */
diff --git a/libnautilus-private/nautilus-directory-async.c b/libnautilus-private/nautilus-directory-async.c
index c6b402ee7..c7bdf3a40 100644
--- a/libnautilus-private/nautilus-directory-async.c
+++ b/libnautilus-private/nautilus-directory-async.c
@@ -1087,6 +1087,27 @@ update_file_info_in_list_if_needed (GList *list,
return TRUE;
}
+static void
+set_file_unconfirmed (NautilusFile *file, gboolean unconfirmed)
+{
+ NautilusDirectory *directory;
+
+ g_assert (NAUTILUS_IS_FILE (file));
+ if (file->details->unconfirmed == unconfirmed) {
+ return;
+ }
+ file->details->unconfirmed = unconfirmed;
+
+ directory = file->details->directory;
+ if (unconfirmed) {
+ directory->details->confirmed_file_count--;
+ }
+ else {
+ directory->details->confirmed_file_count++;
+ }
+}
+
+
static gboolean
dequeue_pending_idle_callback (gpointer callback_data)
{
@@ -1124,7 +1145,7 @@ dequeue_pending_idle_callback (gpointer callback_data)
file = nautilus_directory_find_file (directory, file_info->name);
if (file != NULL) {
/* file already exists, check if it changed */
- file->details->unconfirmed = FALSE;
+ set_file_unconfirmed (file, FALSE);
if (nautilus_file_update_info (file, file_info, FALSE)) {
/* File changed, notify about the change. */
nautilus_file_ref (file);
@@ -1203,7 +1224,7 @@ directory_load_one (NautilusDirectory *directory,
return;
}
gnome_vfs_file_info_ref (info);
- directory->details->pending_file_info
+ directory->details->pending_file_info
= g_list_prepend (directory->details->pending_file_info, info);
nautilus_directory_schedule_dequeue_pending (directory);
}
@@ -1236,7 +1257,7 @@ directory_load_done (NautilusDirectory *directory,
* about them to know whether they are really gone.
*/
for (node = directory->details->file_list; node != NULL; node = node->next) {
- NAUTILUS_FILE (node->data)->details->unconfirmed = FALSE;
+ set_file_unconfirmed (NAUTILUS_FILE (node->data), FALSE);
}
}
@@ -1290,8 +1311,10 @@ directory_load_callback (GnomeVFSAsyncHandle *handle,
}
directory->details->directory_load_list_last_handled = last_handled;
- if (result != GNOME_VFS_OK) {
- directory_load_done (directory, result);
+ if (nautilus_directory_file_list_length_reached (directory) ||
+ result != GNOME_VFS_OK) {
+ directory_load_done (directory,
+ result);
}
}
@@ -1888,8 +1911,7 @@ mark_all_files_unconfirmed (NautilusDirectory *directory)
for (node = directory->details->file_list; node != NULL; node = node->next) {
file = node->data;
-
- file->details->unconfirmed = TRUE;
+ set_file_unconfirmed (file, TRUE);
}
}
@@ -1948,7 +1970,6 @@ nautilus_directory_stop_monitoring_file_list (NautilusDirectory *directory)
directory->details->file_list_monitored = FALSE;
file_list_cancel (directory);
nautilus_file_list_unref (directory->details->file_list);
-
directory->details->directory_loaded = FALSE;
}
diff --git a/libnautilus-private/nautilus-directory-private.h b/libnautilus-private/nautilus-directory-private.h
index a0285931a..e8d4230f1 100644
--- a/libnautilus-private/nautilus-directory-private.h
+++ b/libnautilus-private/nautilus-directory-private.h
@@ -74,6 +74,7 @@ struct NautilusDirectoryDetails
GnomeVFSDirectoryListPosition directory_load_list_last_handled;
GList *pending_file_info; /* list of GnomeVFSFileInfo's that are pending */
+ int confirmed_file_count;
guint dequeue_pending_idle_id;
GList *get_file_infos_in_progress; /* list of GnomeVFSAsyncHandle * */
diff --git a/libnautilus-private/nautilus-directory.c b/libnautilus-private/nautilus-directory.c
index b2c544116..95ca68345 100644
--- a/libnautilus-private/nautilus-directory.c
+++ b/libnautilus-private/nautilus-directory.c
@@ -63,6 +63,9 @@ static guint signals[LAST_SIGNAL];
| GNOME_VFS_PERM_GROUP_ALL \
| GNOME_VFS_PERM_OTHER_ALL)
+/* Hack for PR2 to prevent use of too many resources */
+#define NAUTILUS_DIRECTORY_FILE_LIST_HARD_LIMIT 4000
+
static GHashTable *directories;
static void nautilus_directory_destroy (GtkObject *object);
@@ -550,6 +553,8 @@ nautilus_directory_add_file (NautilusDirectory *directory, NautilusFile *file)
/* Add to hash table. */
add_to_hash_table (directory, file, node);
+ directory->details->confirmed_file_count++;
+
/* Ref if we are monitoring. */
if (nautilus_directory_is_file_list_monitored (directory)) {
nautilus_file_ref (file);
@@ -575,12 +580,23 @@ nautilus_directory_remove_file (NautilusDirectory *directory, NautilusFile *file
(directory->details->file_list, node);
g_list_free_1 (node);
+ if (file->details->unconfirmed == FALSE) {
+ directory->details->confirmed_file_count--;
+ }
+
/* Unref if we are monitoring. */
if (nautilus_directory_is_file_list_monitored (directory)) {
nautilus_file_unref (file);
}
}
+gboolean
+nautilus_directory_file_list_length_reached (NautilusDirectory *directory)
+{
+ return directory->details->confirmed_file_count >= NAUTILUS_DIRECTORY_FILE_LIST_HARD_LIMIT;
+}
+
+
GList *
nautilus_directory_begin_file_name_change (NautilusDirectory *directory,
NautilusFile *file)
diff --git a/libnautilus-private/nautilus-directory.h b/libnautilus-private/nautilus-directory.h
index 8d895d59d..ef58b32e0 100644
--- a/libnautilus-private/nautilus-directory.h
+++ b/libnautilus-private/nautilus-directory.h
@@ -185,4 +185,6 @@ gboolean nautilus_directory_is_local (NautilusDirectory
*/
gboolean nautilus_directory_is_not_empty (NautilusDirectory *directory);
+
+gboolean nautilus_directory_file_list_length_reached (NautilusDirectory *directory);
#endif /* NAUTILUS_DIRECTORY_H */
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index e1d6efff9..033bcf708 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -1348,6 +1348,27 @@ stop_loading_callback (NautilusView *nautilus_view,
static void
+check_for_directory_hard_limit (FMDirectoryView *view)
+{
+ NautilusDirectory *directory;
+ GnomeDialog *dialog;
+
+ directory = view->details->model;
+ if (nautilus_directory_file_list_length_reached (directory)) {
+ dialog = nautilus_warning_dialog (_("We're sorry, but the directory you're viewing has more files than "
+ "we're able to display. As a result, we are only able to show you the "
+ "first 4000 files it contains. "
+ "\n"
+ "This is a temporary limitation in this Preview Release of Nautilus, "
+ "and will not be present in the final shipping version.\n"),
+ _("Too many Files"),
+ get_containing_window (view));
+ }
+
+}
+
+
+static void
done_loading (FMDirectoryView *view)
{
if (!view->details->loading) {
@@ -1359,6 +1380,7 @@ done_loading (FMDirectoryView *view)
if (view->details->nautilus_view != NULL) {
nautilus_view_report_load_complete (view->details->nautilus_view);
schedule_update_menus (view);
+ check_for_directory_hard_limit (view);
}
view->details->loading = FALSE;