[tracker] TrackerMonitor: Double check for is_directory.
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker] TrackerMonitor: Double check for is_directory.
- Date: Thu, 28 Jan 2010 13:33:17 +0000 (UTC)
commit d88a26d0e32c195d2aec390ebf79b0552b0561dd
Author: Carlos Garnacho <carlos lanedo com>
Date: Thu Jan 28 14:23:10 2010 +0100
TrackerMonitor: Double check for is_directory.
at the time the is_directory checks were being done, the file could
no longer exist, so double check these cases with the directory
monitors hashtable, in case we know about it.
src/libtracker-miner/tracker-monitor.c | 32 ++++++++++++++++++++++++++------
1 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-monitor.c b/src/libtracker-miner/tracker-monitor.c
index 13ea4ae..4905a91 100644
--- a/src/libtracker-miner/tracker-monitor.c
+++ b/src/libtracker-miner/tracker-monitor.c
@@ -582,6 +582,29 @@ libinotify_monitor_event_to_string (guint32 event_type)
}
static gboolean
+check_is_directory (TrackerMonitor *monitor,
+ GFile *file)
+{
+ GFileType file_type;
+
+ file_type = g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE, NULL);
+
+ if (file_type == G_FILE_TYPE_DIRECTORY)
+ return TRUE;
+
+ if (file_type == G_FILE_TYPE_UNKNOWN) {
+ /* Whatever it was, it's gone. Check the monitors
+ * hashtable to know whether it was a directory
+ * we knew about
+ */
+ if (g_hash_table_lookup (monitor->private->monitors, file) != NULL)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
libinotify_event_pairs_timeout_cb (gpointer data)
{
TrackerMonitor *monitor;
@@ -627,8 +650,7 @@ libinotify_event_pairs_timeout_cb (gpointer data)
GPOINTER_TO_UINT (key),
seconds);
- is_directory =
- g_file_query_file_type (event->file, G_FILE_QUERY_INFO_NONE, NULL) == G_FILE_TYPE_DIRECTORY;
+ is_directory = check_is_directory (monitor, event->file);
switch (event->event_type) {
case IN_MOVED_FROM:
@@ -753,8 +775,7 @@ libinotify_cached_events_timeout_cb (gpointer data)
last_event_seconds = now.tv_sec - event->last_time.tv_sec;
start_event_seconds = now.tv_sec - event->start_time.tv_sec;
- is_directory =
- g_file_query_file_type (event->file, G_FILE_QUERY_INFO_NONE, NULL) == G_FILE_TYPE_DIRECTORY;
+ is_directory = check_is_directory (monitor, event->file);
g_debug ("Comparing now:%ld to then:%ld (start:%ld), diff:%ld (with start:%ld)",
now.tv_sec,
@@ -928,8 +949,7 @@ libinotify_monitor_event_cb (INotifyHandle *handle,
str1 = g_file_get_path (file);
}
- is_directory =
- g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE, NULL) == G_FILE_TYPE_DIRECTORY;
+ is_directory = check_is_directory (monitor, file);
event_type_str = libinotify_monitor_event_to_string (event_type);
g_message ("Received monitor event:%d->'%s' for file:'%s' (cookie:%d)",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]