Commit 43e13a68 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Add nautilus_directory_has_active_request_for_file which returns true if

2008-10-17  Alexander Larsson  <alexl@redhat.com>

        * libnautilus-private/nautilus-directory-async.c:
        * libnautilus-private/nautilus-directory-private.h:
        Add nautilus_directory_has_active_request_for_file which returns true
	if monitoring or call_when_ready the file or all the files in the directory.
        * libnautilus-private/nautilus-directory.c:
        (nautilus_directory_add_file):
	When adding a file to a directory, if there is an outstanding request
	for the file, add it to the work queue so we make sure to do i/o on it.
	Otherwise we could for instance block a call_when_ready with file=NULL
	because we're waiting for something to happen on all files in the dir
	but the newly added file never has any i/o happen to it.


svn path=/trunk/; revision=14736
parent 082fc747
2008-10-17 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-directory-async.c:
* libnautilus-private/nautilus-directory-private.h:
Add nautilus_directory_has_active_request_for_file which returns true
if monitoring or call_when_ready the file or all the files in the directory.
* libnautilus-private/nautilus-directory.c:
(nautilus_directory_add_file):
When adding a file to a directory, if there is an outstanding request
for the file, add it to the work queue so we make sure to do i/o on it.
Otherwise we could for instance block a call_when_ready with file=NULL
because we're waiting for something to happen on all files in the dir
but the newly added file never has any i/o happen to it.
2008-10-17 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-bookmark.c:
......
......@@ -1964,6 +1964,36 @@ call_ready_callbacks (NautilusDirectory *directory)
return found_any;
}
gboolean
nautilus_directory_has_active_request_for_file (NautilusDirectory *directory,
NautilusFile *file)
{
GList *node;
ReadyCallback *callback;
Monitor *monitor;
for (node = directory->details->call_when_ready_list;
node != NULL; node = node->next) {
callback = node->data;
if (callback->file == file ||
callback->file == NULL) {
return TRUE;
}
}
for (node = directory->details->monitor_list;
node != NULL; node = node->next) {
monitor = node->data;
if (monitor->file == file ||
monitor->file == NULL) {
return TRUE;
}
}
return FALSE;
}
/* This checks if there's a request for monitoring the file list. */
gboolean
nautilus_directory_is_anyone_monitoring_file_list (NautilusDirectory *directory)
......
......@@ -172,6 +172,8 @@ NautilusFile * nautilus_directory_get_existing_corresponding_file (NautilusD
void nautilus_directory_invalidate_count_and_mime_list (NautilusDirectory *directory);
gboolean nautilus_directory_is_file_list_monitored (NautilusDirectory *directory);
gboolean nautilus_directory_is_anyone_monitoring_file_list (NautilusDirectory *directory);
gboolean nautilus_directory_has_active_request_for_file (NautilusDirectory *directory,
NautilusFile *file);
void nautilus_directory_remove_file_monitor_link (NautilusDirectory *directory,
GList *link);
void nautilus_directory_schedule_dequeue_pending (NautilusDirectory *directory);
......
......@@ -633,6 +633,7 @@ void
nautilus_directory_add_file (NautilusDirectory *directory, NautilusFile *file)
{
GList *node;
gboolean add_to_work_queue;
g_assert (NAUTILUS_IS_DIRECTORY (directory));
g_assert (NAUTILUS_IS_FILE (file));
......@@ -647,9 +648,19 @@ nautilus_directory_add_file (NautilusDirectory *directory, NautilusFile *file)
directory->details->confirmed_file_count++;
/* Ref if we are monitoring. */
add_to_work_queue = FALSE;
if (nautilus_directory_is_file_list_monitored (directory)) {
/* Ref if we are monitoring, since monitoring owns the file list. */
nautilus_file_ref (file);
add_to_work_queue = TRUE;
} else if (nautilus_directory_has_active_request_for_file (directory, file)) {
/* We're waiting for the file in a call_when_ready. Make sure
we add the file to the work queue so that said waiter won't
wait forever for e.g. all files in the directory to be done */
add_to_work_queue = TRUE;
}
if (add_to_work_queue) {
nautilus_directory_add_file_to_work_queue (directory, file);
}
}
......
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