Commit 0c65eaca authored by Rebecca Schulman's avatar Rebecca Schulman Committed by Rebecca Schulman

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.
parent 560bc567
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:
......
......@@ -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;
}
......
......@@ -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 * */
......
......@@ -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)
......
......@@ -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 */
......@@ -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;
}
......
......@@ -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 * */
......
......@@ -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)
......
......@@ -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 */
......@@ -1347,6 +1347,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)
{
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment