[tracker/external-crawler: 16/37] libtracker-miner: Added TrackerEnumerator interface, TrackerFileEnumerator class



commit 01018610455e3ce5e0784d7688aa7f38e6c046bf
Author: Martyn Russell <martyn lanedo com>
Date:   Thu Jun 5 12:32:08 2014 +0100

    libtracker-miner: Added TrackerEnumerator interface, TrackerFileEnumerator class
    
    These are used to enumerate over children of a URI. The TrackerFileEnumerator
    uses GFileEnumerator and the TrackerEnumerator allows for other
    implementations to supply GFile/GFileInfo data to Tracker for 3rd parties.
    
    Updated MinerFS TrackerDirectory flags for external crawlers

 src/libtracker-miner/Makefile.am               |    6 +-
 src/libtracker-miner/tracker-enumerator.c      |  106 ++++++++++
 src/libtracker-miner/tracker-enumerator.h      |   86 ++++++++
 src/libtracker-miner/tracker-file-enumerator.c |  255 ++++++++++++++++++++++++
 src/libtracker-miner/tracker-file-enumerator.h |   49 +++++
 src/libtracker-miner/tracker-miner-fs.c        |   57 ++++--
 src/libtracker-miner/tracker-miner.h           |    2 +-
 7 files changed, 542 insertions(+), 19 deletions(-)
---
diff --git a/src/libtracker-miner/Makefile.am b/src/libtracker-miner/Makefile.am
index 4311353..2837c39 100644
--- a/src/libtracker-miner/Makefile.am
+++ b/src/libtracker-miner/Makefile.am
@@ -31,8 +31,10 @@ libtracker_minerdir = $(libdir)/tracker-$(TRACKER_API_VERSION)
 libtracker_minerincludedir=$(includedir)/tracker-$(TRACKER_API_VERSION)/libtracker-miner/
 
 private_sources =                                     \
-       tracker-crawler.c                              \
-       tracker-crawler.h                              \
+       tracker-enumerator.c                           \
+       tracker-enumerator.h                           \
+       tracker-file-enumerator.c                      \
+       tracker-file-enumerator.h                      \
        tracker-file-notifier.h                        \
        tracker-file-notifier.c                        \
        tracker-file-system.h                          \
diff --git a/src/libtracker-miner/tracker-enumerator.c b/src/libtracker-miner/tracker-enumerator.c
new file mode 100644
index 0000000..b3cb8ef
--- /dev/null
+++ b/src/libtracker-miner/tracker-enumerator.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2014, Softathome <contact softathome com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ *
+ * Author: Martyn Russell <martyn lanedo com>
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include "tracker-enumerator.h"
+
+typedef TrackerEnumeratorIface TrackerEnumeratorInterface;
+G_DEFINE_INTERFACE (TrackerEnumerator, tracker_enumerator, G_TYPE_OBJECT)
+
+static void
+tracker_enumerator_default_init (TrackerEnumeratorInterface *iface)
+{
+}
+
+GSList *
+tracker_enumerator_start (TrackerEnumerator    *enumerator,
+                          GFile                *dir,
+                          const gchar          *attributes,
+                          GFileQueryInfoFlags   flags,
+                          GCancellable         *cancellable,
+                          GError              **error)
+{
+       TrackerEnumeratorIface *iface;
+
+       g_return_val_if_fail (TRACKER_IS_ENUMERATOR (enumerator), NULL);
+
+       if (g_cancellable_set_error_if_cancelled (cancellable, error)) {
+               return NULL;
+       }
+
+       iface = TRACKER_ENUMERATOR_GET_IFACE (enumerator);
+
+       if (iface->start == NULL) {
+               g_set_error_literal (error,
+                                    G_IO_ERROR,
+                                    G_IO_ERROR_NOT_SUPPORTED,
+                                    _("Operation not supported"));
+               return NULL;
+       }
+
+       return (* iface->start) (enumerator, dir, attributes, flags, cancellable, error);
+}
+
+void
+tracker_enumerator_start_async (TrackerEnumerator    *enumerator,
+                                GFile                *dir,
+                                const gchar          *attributes,
+                                GFileQueryInfoFlags   flags,
+                                int                   io_priority,
+                                GCancellable         *cancellable,
+                                GAsyncReadyCallback   callback,
+                                gpointer              user_data)
+{
+       TrackerEnumeratorIface *iface;
+
+       g_return_if_fail (TRACKER_IS_ENUMERATOR (enumerator));
+
+       iface = TRACKER_ENUMERATOR_GET_IFACE (enumerator);
+
+       if (iface->start_async == NULL) {
+               g_critical (_("Operation not supported"));
+               return;
+       }
+
+       (* iface->start_async) (enumerator, dir, attributes, flags, io_priority, cancellable, callback, 
user_data);
+}
+
+GSList *
+tracker_enumerator_start_finish (TrackerEnumerator  *enumerator,
+                                 GAsyncResult       *result,
+                                 GError            **error)
+{
+       TrackerEnumeratorIface *iface;
+
+       g_return_val_if_fail (TRACKER_IS_ENUMERATOR (enumerator), NULL);
+       g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
+
+       iface = TRACKER_ENUMERATOR_GET_IFACE (enumerator);
+
+       if (g_async_result_legacy_propagate_error (result, error)) {
+               return NULL;
+       }
+
+       return (* iface->start_finish) (enumerator, result, error);
+}
diff --git a/src/libtracker-miner/tracker-enumerator.h b/src/libtracker-miner/tracker-enumerator.h
new file mode 100644
index 0000000..9525bcf
--- /dev/null
+++ b/src/libtracker-miner/tracker-enumerator.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2014, Softathome <contact softathome com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ *
+ * Author: Martyn Russell <martyn lanedo com>
+ */
+
+#ifndef __LIBTRACKER_MINER_ENUMERATOR_H__
+#define __LIBTRACKER_MINER_ENUMERATOR_H__
+
+#if !defined (__LIBTRACKER_MINER_H_INSIDE__) && !defined (TRACKER_COMPILATION)
+#error "Only <libtracker-miner/tracker-miner.h> can be included directly."
+#endif
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define TRACKER_TYPE_ENUMERATOR           (tracker_enumerator_get_type ())
+#define TRACKER_ENUMERATOR(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRACKER_TYPE_ENUMERATOR, 
TrackerEnumerator))
+#define TRACKER_IS_ENUMERATOR(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRACKER_TYPE_ENUMERATOR))
+#define TRACKER_ENUMERATOR_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TRACKER_TYPE_ENUMERATOR, 
TrackerEnumeratorIface))
+
+typedef struct _TrackerEnumerator TrackerEnumerator;
+typedef struct _TrackerEnumeratorIface TrackerEnumeratorIface;
+
+struct _TrackerEnumeratorIface {
+       GTypeInterface g_iface;
+
+       /* Virtual Table */
+       GSList * (* start)        (TrackerEnumerator    *enumerator,
+                                  GFile                *dir,
+                                  const gchar          *attributes,
+                                  GFileQueryInfoFlags   flags,
+                                  GCancellable         *cancellable,
+                                  GError              **error);
+       void     (* start_async)  (TrackerEnumerator    *enumerator,
+                                  GFile                *dir,
+                                  const gchar          *attributes,
+                                  GFileQueryInfoFlags   flags,
+                                  int                   io_priority,
+                                  GCancellable         *cancellable,
+                                  GAsyncReadyCallback   callback,
+                                  gpointer              user_data);
+       GSList * (* start_finish) (TrackerEnumerator    *enumerator,
+                                  GAsyncResult         *result,
+                                  GError              **error);
+
+};
+
+GType   tracker_enumerator_get_type      (void) G_GNUC_CONST;
+GSList *tracker_enumerator_start         (TrackerEnumerator    *enumerator,
+                                          GFile                *dir,
+                                          const gchar          *attributes,
+                                          GFileQueryInfoFlags   flags,
+                                          GCancellable         *cancellable,
+                                          GError              **error);
+void    tracker_enumerator_start_async   (TrackerEnumerator    *enumerator,
+                                          GFile                *dir,
+                                          const gchar          *attributes,
+                                          GFileQueryInfoFlags   flags,
+                                          int                   io_priority,
+                                          GCancellable         *cancellable,
+                                          GAsyncReadyCallback   callback,
+                                          gpointer              user_data);
+GSList *tracker_enumerator_start_finish  (TrackerEnumerator    *enumerator,
+                                          GAsyncResult         *result,
+                                          GError              **error);
+
+G_END_DECLS
+
+#endif /* __LIBTRACKER_MINER_ENUMERATOR_H__ */
diff --git a/src/libtracker-miner/tracker-file-enumerator.c b/src/libtracker-miner/tracker-file-enumerator.c
new file mode 100644
index 0000000..43b055f
--- /dev/null
+++ b/src/libtracker-miner/tracker-file-enumerator.c
@@ -0,0 +1,255 @@
+/*
+ * Copyright (C) 2014, Softathome <contact softathome com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ *
+ * Author: Martyn Russell <martyn lanedo com>
+ */
+
+#include "config.h"
+
+#include "tracker-file-enumerator.h"
+
+static void tracker_file_enumerator_file_iface_init (TrackerEnumeratorIface *iface);
+
+struct _TrackerFileEnumerator {
+       GObject parent_instance;
+};
+
+typedef struct {
+       GFile *dir;
+       gchar *attributes;
+       GFileQueryInfoFlags flags;
+} StartData;
+
+G_DEFINE_TYPE_WITH_CODE (TrackerFileEnumerator, tracker_file_enumerator, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (TRACKER_TYPE_ENUMERATOR,
+                                                tracker_file_enumerator_file_iface_init))
+
+static void
+tracker_file_enumerator_finalize (GObject *object)
+{
+       G_OBJECT_CLASS (tracker_file_enumerator_parent_class)->finalize (object);
+}
+
+static void
+tracker_file_enumerator_class_init (TrackerFileEnumeratorClass *klass)
+{
+       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+       gobject_class->finalize = tracker_file_enumerator_finalize;
+}
+
+static void
+tracker_file_enumerator_init (TrackerFileEnumerator *fe)
+{
+}
+
+
+static StartData *
+start_data_new (GFile               *dir,
+                const gchar         *attributes,
+                GFileQueryInfoFlags  flags)
+{
+       StartData *data;
+
+       data = g_slice_new0 (StartData);
+       data->dir = g_object_ref (dir);
+       /* FIXME: inefficient */
+       data->attributes = g_strdup (attributes);
+       data->flags = flags;
+
+       return data;
+}
+
+static void
+start_data_free (StartData *data)
+{
+       if (!data) {
+               return;
+       }
+
+       g_object_unref (data->dir);
+       g_free (data->attributes);
+       g_slice_free (StartData, data);
+}
+
+static GSList *
+file_enumerator_start (TrackerEnumerator    *enumerator,
+                       GFile                *dir,
+                       const gchar          *attributes,
+                       GFileQueryInfoFlags   flags,
+                       GCancellable         *cancellable,
+                       GError              **error)
+{
+       GFileEnumerator *fe;
+       GSList *files;
+       GError *local_error = NULL;
+       gboolean cancelled;
+
+       fe = g_file_enumerate_children (dir,
+                                       attributes,
+                                       flags,
+                                       cancellable,
+                                       &local_error);
+
+
+       cancelled = g_cancellable_is_cancelled (cancellable);
+
+       if (!enumerator) {
+               if (local_error && !cancelled) {
+                       gchar *path;
+
+                       path = g_file_get_path (dir);
+
+                       g_warning ("Could not open directory '%s': %s",
+                                  path, local_error->message);
+
+                       g_propagate_error (error, local_error);
+                       g_free (path);
+               }
+
+               return NULL;
+       }
+
+       files = NULL;
+
+       /* May as well be while TRUE ... */
+       while (!cancelled) {
+               GFileInfo *info;
+
+               info = g_file_enumerator_next_file (fe, cancellable, &local_error);
+
+               /* FIXME: Do we need a ->is_running check here like before? */
+               if (local_error || !info) {
+                       if (local_error && !cancelled) {
+                               g_critical ("Could not crawl through directory: %s", local_error->message);
+                               g_propagate_error (error, local_error);
+                       }
+
+                       /* No more files or we are stopping anyway, so clean
+                        * up and close all file enumerators.
+                        */
+                       if (info) {
+                               g_object_unref (info);
+                       }
+
+                       /* FIXME: We need some check here to call
+                        * enumerator_data_process which signals
+                        * CHECK_DIRECTORY_CONTENTS
+                        */
+                       g_file_enumerator_close (fe, NULL, &local_error);
+
+                       if (local_error) {
+                               g_warning ("Couldn't close GFileEnumerator (%p): %s", fe,
+                                          local_error ? local_error->message : "No reason");
+                               g_propagate_error (error, local_error);
+                       }
+
+                       g_object_unref (fe);
+
+                       break;
+               }
+
+               files = g_slist_prepend (files, info);
+       }
+
+       return g_slist_reverse (files);
+}
+
+static void
+start_async_thread_op_free (GSList *files)
+{
+       g_slist_free_full (files, g_object_unref);
+}
+
+static void
+start_async_thread (GTask        *task,
+                    gpointer      source_object,
+                    gpointer      task_data,
+                    GCancellable *cancellable)
+{
+       TrackerEnumerator *enumerator = source_object;
+       StartData *data = task_data;
+       GSList *files = NULL;
+       GError *error = NULL;
+
+       if (g_cancellable_set_error_if_cancelled (cancellable, &error)) {
+               files = NULL;
+       } else {
+               files = file_enumerator_start (enumerator,
+                                              data->dir,
+                                              data->attributes,
+                                              data->flags,
+                                              cancellable,
+                                              &error);
+       }
+
+       if (error) {
+               g_task_return_error (task, error);
+       } else {
+               g_task_return_pointer (task, files, (GDestroyNotify) start_async_thread_op_free);
+       }
+}
+
+static void
+file_enumerator_start_async (TrackerEnumerator    *enumerator,
+                             GFile                *dir,
+                             const gchar          *attributes,
+                             GFileQueryInfoFlags   flags,
+                             int                   io_priority,
+                             GCancellable         *cancellable,
+                             GAsyncReadyCallback   callback,
+                             gpointer              user_data)
+{
+       GTask *task;
+
+       task = g_task_new (enumerator, cancellable, callback, user_data);
+       g_task_set_task_data (task, start_data_new (dir, attributes, flags), (GDestroyNotify) 
start_data_free);
+       g_task_set_priority (task, io_priority);
+
+       g_task_run_in_thread (task, start_async_thread);
+       g_object_unref (task);
+}
+
+static GSList *
+file_enumerator_start_finish (TrackerEnumerator  *enumerator,
+                              GAsyncResult       *result,
+                              GError            **error)
+{
+       g_return_val_if_fail (g_task_is_valid (result, enumerator), NULL);
+
+       return g_task_propagate_pointer (G_TASK (result), error);
+}
+
+
+static void
+tracker_file_enumerator_file_iface_init (TrackerEnumeratorIface *iface)
+{
+       iface->start = file_enumerator_start;
+       iface->start_async = file_enumerator_start_async;
+       iface->start_finish = file_enumerator_start_finish;
+}
+
+TrackerEnumerator *
+tracker_file_enumerator_new (void)
+{
+       TrackerFileEnumerator *tfe;
+
+       tfe = g_object_new (TRACKER_TYPE_FILE_ENUMERATOR, NULL);
+
+       return TRACKER_ENUMERATOR (tfe);
+}
diff --git a/src/libtracker-miner/tracker-file-enumerator.h b/src/libtracker-miner/tracker-file-enumerator.h
new file mode 100644
index 0000000..4ac3800
--- /dev/null
+++ b/src/libtracker-miner/tracker-file-enumerator.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2014, Softathome <contact softathome com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ *
+ * Author: Martyn Russell <martyn lanedo com>
+ */
+
+#ifndef __LIBTRACKER_MINER_FILE_ENUMERATOR_H__
+#define __LIBTRACKER_MINER_FILE_ENUMERATOR_H__
+
+#include <gio/gio.h>
+#include "tracker-enumerator.h"
+
+G_BEGIN_DECLS
+
+#define TRACKER_TYPE_FILE_ENUMERATOR         (tracker_file_enumerator_get_type ())
+#define TRACKER_FILE_ENUMERATOR(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_FILE_ENUMERATOR, 
TrackerFileEnumerator))
+#define TRACKER_FILE_ENUMERATOR_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), TRACKER_TYPE_FILE_ENUMERATOR, 
TrackerFileEnumeratorClass))
+#define TRACKER_IS_FILE_ENUMERATOR(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_FILE_ENUMERATOR))
+#define TRACKER_IS_FILE_ENUMERATOR_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), TRACKER_TYPE_FILE_ENUMERATOR))
+#define TRACKER_FILE_ENUMERATOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_FILE_ENUMERATOR, 
TrackerFileEnumeratorClass))
+
+typedef struct _TrackerFileEnumerator        TrackerFileEnumerator;
+typedef struct _TrackerFileEnumeratorClass   TrackerFileEnumeratorClass;
+
+struct _TrackerFileEnumeratorClass {
+       GObjectClass parent_class;
+};
+
+GType               tracker_file_enumerator_get_type (void) G_GNUC_CONST;
+TrackerEnumerator * tracker_file_enumerator_new      (void);
+
+G_END_DECLS
+
+#endif /* __LIBTRACKERMINER_FILE_ENUMERATOR_H__ */
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index d14e134..6c2c95d 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -3021,23 +3021,26 @@ tracker_miner_fs_directory_add (TrackerMinerFS *fs,
                                 GFile          *file,
                                 gboolean        recurse)
 {
-       TrackerDirectoryFlags flags;
+       TrackerDirectoryFlags flags = TRACKER_DIRECTORY_FLAG_NONE;
 
        g_return_if_fail (TRACKER_IS_MINER_FS (fs));
        g_return_if_fail (G_IS_FILE (file));
 
-       flags = TRACKER_DIRECTORY_FLAG_MONITOR;
-
        if (recurse) {
                flags |= TRACKER_DIRECTORY_FLAG_RECURSE;
        }
 
-       if (fs->priv->mtime_checking) {
-               flags |= TRACKER_DIRECTORY_FLAG_CHECK_MTIME;
+       if (!fs->priv->external_crawler) {
+               flags |= TRACKER_DIRECTORY_FLAG_MONITOR;
+
+               if (fs->priv->mtime_checking) {
+                       flags |= TRACKER_DIRECTORY_FLAG_CHECK_MTIME;
+               }
        }
 
        tracker_indexing_tree_add (fs->priv->indexing_tree,
-                                  file, flags);
+                                  file,
+                                  flags);
 }
 
 static void
@@ -3465,9 +3468,13 @@ tracker_miner_fs_check_directory_with_priority (TrackerMinerFS *fs,
                        return;
                }
 
-               flags = TRACKER_DIRECTORY_FLAG_RECURSE |
-                       TRACKER_DIRECTORY_FLAG_CHECK_MTIME |
-                       TRACKER_DIRECTORY_FLAG_MONITOR;
+               if (fs->priv->external_crawler) {
+                       flags = TRACKER_DIRECTORY_FLAG_RECURSE;
+               } else {
+                       flags = TRACKER_DIRECTORY_FLAG_RECURSE |
+                               TRACKER_DIRECTORY_FLAG_CHECK_MTIME |
+                               TRACKER_DIRECTORY_FLAG_MONITOR;
+               }
 
                /* Priorities run from positive to negative */
                if (priority < G_PRIORITY_DEFAULT)
@@ -3840,14 +3847,23 @@ void
 tracker_miner_fs_force_mtime_checking (TrackerMinerFS *fs,
                                        GFile          *directory)
 {
+       TrackerDirectoryFlags flags;
+
        g_return_if_fail (TRACKER_IS_MINER_FS (fs));
        g_return_if_fail (G_IS_FILE (directory));
 
+       if (fs->priv->external_crawler) {
+               /* Essentially, this is a not doing anything special */
+               flags = TRACKER_DIRECTORY_FLAG_RECURSE;
+       } else {
+               flags = TRACKER_DIRECTORY_FLAG_RECURSE |
+                       TRACKER_DIRECTORY_FLAG_CHECK_MTIME |
+                       TRACKER_DIRECTORY_FLAG_MONITOR;
+       }
+
        tracker_indexing_tree_add (fs->priv->indexing_tree,
                                   directory,
-                                  TRACKER_DIRECTORY_FLAG_CHECK_MTIME |
-                                  TRACKER_DIRECTORY_FLAG_RECURSE |
-                                  TRACKER_DIRECTORY_FLAG_MONITOR);
+                                  flags);
 }
 
 void
@@ -3910,15 +3926,24 @@ void
 tracker_miner_fs_add_directory_without_parent (TrackerMinerFS *fs,
                                                GFile          *file)
 {
+       TrackerDirectoryFlags flags;
+
        g_return_if_fail (TRACKER_IS_MINER_FS (fs));
        g_return_if_fail (G_IS_FILE (file));
 
+       if (fs->priv->external_crawler) {
+               flags = TRACKER_DIRECTORY_FLAG_RECURSE |
+                       TRACKER_DIRECTORY_FLAG_PRESERVE;
+       } else {
+               flags = TRACKER_DIRECTORY_FLAG_RECURSE |
+                       TRACKER_DIRECTORY_FLAG_PRESERVE |
+                       TRACKER_DIRECTORY_FLAG_CHECK_MTIME |
+                       TRACKER_DIRECTORY_FLAG_MONITOR;
+       }
+
        tracker_indexing_tree_add (fs->priv->indexing_tree,
                                   file,
-                                  TRACKER_DIRECTORY_FLAG_RECURSE |
-                                  TRACKER_DIRECTORY_FLAG_CHECK_MTIME |
-                                  TRACKER_DIRECTORY_FLAG_MONITOR |
-                                  TRACKER_DIRECTORY_FLAG_PRESERVE);
+                                  flags);
 }
 
 /**
diff --git a/src/libtracker-miner/tracker-miner.h b/src/libtracker-miner/tracker-miner.h
index 9c5ec64..d437385 100644
--- a/src/libtracker-miner/tracker-miner.h
+++ b/src/libtracker-miner/tracker-miner.h
@@ -22,6 +22,7 @@
 
 #define __LIBTRACKER_MINER_H_INSIDE__
 
+#include <libtracker-miner/tracker-enumerator.h>
 #include <libtracker-miner/tracker-decorator.h>
 #include <libtracker-miner/tracker-decorator-fs.h>
 #include <libtracker-miner/tracker-miner-object.h>
@@ -31,7 +32,6 @@
 #include <libtracker-miner/tracker-miner-enum-types.h>
 #include <libtracker-miner/tracker-indexing-tree.h>
 
-
 #undef __LIBTRACKER_MINER_H_INSIDE__
 
 #endif /* __LIBTRACKER_MINER_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]