tracker r2106 - in branches/indexer-split: . src/tracker-indexer
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2106 - in branches/indexer-split: . src/tracker-indexer
- Date: Tue, 19 Aug 2008 15:55:48 +0000 (UTC)
Author: carlosg
Date: Tue Aug 19 15:55:48 2008
New Revision: 2106
URL: http://svn.gnome.org/viewvc/tracker?rev=2106&view=rev
Log:
2008-08-19 Carlos Garnacho <carlos imendio com>
* src/tracker-indexer/tracker-indexer-db.[ch]
(tracker_db_check_service): Modify to also get mtime.
* src/tracker-indexer/tracker-indexer.c: Update all callers.
(should_index_file) (process_file): Check mtimes before reindexing a
file.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c
branches/indexer-split/src/tracker-indexer/tracker-indexer-db.h
branches/indexer-split/src/tracker-indexer/tracker-indexer.c
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c Tue Aug 19 15:55:48 2008
@@ -142,14 +142,19 @@
g_free (service_id_str);
}
-guint
-tracker_db_check_service (TrackerService *service,
- const gchar *dirname,
- const gchar *basename)
+gboolean
+tracker_db_check_service (TrackerService *service,
+ const gchar *dirname,
+ const gchar *basename,
+ guint32 *id,
+ time_t *mtime)
{
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
- guint id;
+ guint db_id, db_mtime;
+ gboolean found = FALSE;
+
+ db_id = db_mtime = 0;
iface = tracker_db_manager_get_db_interface_by_type (tracker_service_get_name (service),
TRACKER_DB_CONTENT_TYPE_METADATA);
@@ -159,14 +164,24 @@
dirname,
basename,
NULL);
- if (!result_set) {
- return 0;
+ if (result_set) {
+ tracker_db_result_set_get (result_set,
+ 0, &db_id,
+ 1, &db_mtime,
+ -1);
+ g_object_unref (result_set);
+ found = TRUE;
}
- tracker_db_result_set_get (result_set, 0, &id, -1);
- g_object_unref (result_set);
+ if (id) {
+ *id = (guint32) db_id;
+ }
+
+ if (mtime) {
+ *mtime = (time_t) db_mtime;
+ }
- return id;
+ return found;
}
guint
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer-db.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer-db.h (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer-db.h Tue Aug 19 15:55:48 2008
@@ -33,9 +33,11 @@
void tracker_db_decrement_stats (TrackerDBInterface *iface,
TrackerService *service);
/* Using path */
-guint tracker_db_check_service (TrackerService *service,
+gboolean tracker_db_check_service (TrackerService *service,
const gchar *dirname,
- const gchar *basename);
+ const gchar *basename,
+ guint32 *id,
+ time_t *mtime);
guint tracker_db_get_service_type (const gchar *dirname,
const gchar *basename);
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.c Tue Aug 19 15:55:48 2008
@@ -1092,10 +1092,11 @@
static void
create_update_item (TrackerIndexer *indexer,
PathInfo *info,
+ const gchar *dirname,
+ const gchar *basename,
TrackerMetadata *metadata)
{
TrackerService *service_def;
- gchar *dirname, *basename;
gchar *service_type;
gchar *text;
guint32 id;
@@ -1108,19 +1109,9 @@
return;
}
- tracker_indexer_module_file_get_uri (info->module,
- info->file,
- &dirname,
- &basename);
- id = tracker_db_check_service (service_def,
- dirname,
- basename);
-
g_debug ("Processing item:'%s/%s'", dirname, basename);
- /* FIXME: should check mtime and reindex if necessary */
-
- if (id == 0) {
+ if (!tracker_db_check_service (service_def, dirname, basename, &id, NULL)) {
/* Service wasn't previously indexed */
id = tracker_db_get_new_service_id (indexer->private->common);
@@ -1206,33 +1197,21 @@
g_free (old_text);
g_free (new_text);
}
-
- g_free (dirname);
- g_free (basename);
}
static void
delete_item (TrackerIndexer *indexer,
- PathInfo *info)
+ PathInfo *info,
+ const gchar *dirname,
+ const gchar *basename)
{
TrackerService *service_def;
- gchar *dirname;
- gchar *basename;
- gchar *content;
- gchar *metadata;
+ gchar *content, *metadata;
const gchar *service_type;
- guint service_id;
- guint service_type_id;
+ guint service_id, service_type_id;
service_type = tracker_module_config_get_index_service (info->module_name);
- if (!tracker_indexer_module_file_get_uri (info->module,
- info->file,
- &dirname,
- &basename)) {
- return;
- }
-
g_debug ("Deleting item:'%s/%s'", dirname, basename);
if (!service_type || !service_type[0]) {
@@ -1245,8 +1224,6 @@
if (service_type_id == 0) {
/* File didn't exist, nothing to delete */
- g_free (dirname);
- g_free (basename);
return;
}
@@ -1258,10 +1235,7 @@
service_type_id = tracker_service_get_id (service_def);
}
- service_id = tracker_db_check_service (service_def, dirname, basename);
-
- g_free (dirname);
- g_free (basename);
+ tracker_db_check_service (service_def, dirname, basename, &service_id, NULL);
if (service_id < 1) {
g_debug ("Can not delete file, it doesnt exist in DB");
@@ -1369,10 +1343,11 @@
dirname = tracker_file_get_vfs_path (uri);
basename = tracker_file_get_vfs_name (uri);
- service_id = tracker_db_check_service (service_def,
- dirname,
- basename);
-
+ tracker_db_check_service (service_def,
+ dirname,
+ basename,
+ &service_id,
+ NULL);
g_free (dirname);
g_free (basename);
@@ -1493,7 +1468,7 @@
dirname = tracker_file_get_vfs_path (uri);
basename = tracker_file_get_vfs_name (uri);
- service_id = tracker_db_check_service (service_def, dirname, basename);
+ tracker_db_check_service (service_def, dirname, basename, &service_id, NULL);
g_free (dirname);
g_free (basename);
@@ -1556,15 +1531,60 @@
}
static gboolean
+should_index_file (PathInfo *info,
+ const gchar *dirname,
+ const gchar *basename)
+{
+ TrackerService *service;
+ gchar *service_type;
+ struct stat st;
+ guint id;
+ time_t mtime;
+
+ service_type = tracker_indexer_module_file_get_service_type (info->module, info->file);
+ service = tracker_ontology_get_service_type_by_name (service_type);
+ g_free (service_type);
+
+ if (!service) {
+ return TRUE;
+ }
+
+ if (!tracker_db_check_service (service, dirname, basename, &id, &mtime)) {
+ return TRUE;
+ }
+
+ if (g_lstat ((const gchar *) info->file->path, &st) == -1) {
+ return TRUE;
+ }
+
+ return (st.st_mtime > mtime);
+}
+
+static gboolean
process_file (TrackerIndexer *indexer,
PathInfo *info)
{
TrackerMetadata *metadata;
+ gchar *dirname, *basename;
/* Set the current module */
g_free (indexer->private->current_module_name);
indexer->private->current_module_name = g_strdup (info->module_name);
+ if (!tracker_indexer_module_file_get_uri (info->module,
+ info->file,
+ &dirname,
+ &basename)) {
+ return TRUE;
+ }
+
+ if (!should_index_file (info, dirname, basename)) {
+ g_debug ("File is already up to date: '%s'", info->file->path);
+ g_free (dirname);
+ g_free (basename);
+ return TRUE;
+ }
+
/* Sleep to throttle back indexing */
tracker_throttle (indexer->private->config, 100);
@@ -1572,14 +1592,17 @@
if (metadata) {
/* Create/Update item */
- create_update_item (indexer, info, metadata);
+ create_update_item (indexer, info, dirname, basename, metadata);
tracker_metadata_free (metadata);
} else {
- delete_item (indexer, info);
+ delete_item (indexer, info, dirname, basename);
}
indexer->private->items_processed++;
+ g_free (dirname);
+ g_free (basename);
+
return !tracker_indexer_module_file_iter_contents (info->module, info->file);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]