[tracker/tracker-0.6] Fixes NB#111735, some times tracker is still listing the files from the deleted folders.
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker/tracker-0.6] Fixes NB#111735, some times tracker is still listing the files from the deleted folders.
- Date: Tue, 21 Apr 2009 07:10:14 -0400 (EDT)
commit 130df00592d21653cbd170c237da9e6354db3841
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Apr 21 12:57:58 2009 +0200
Fixes NB#111735, some times tracker is still listing the files from the deleted folders.
* data/db/sqlite-stored-procs.sql: Also retrieve the Enabled value in
GetServiceID.
* src/libtracker-data/tracker-data-query.[ch] (tracker_data_query_file_id)
(tracker_data_query_service_type_id): Interpret disabled services as
nonexistent.
(tracker_data_query_service_exists): Add extra argument for the Enabled field.
* src/tracker-indexer/tracker-indexer.c (item_add_or_update) (item_move)
(item_mark_for_removal) (handle_metadata_add) (handle_metadata_remove)
(should_change_index_for_file): Take into account disabled services, and act
accordingly if we step on one of these (Either take as nonexistent, or
delete prior to any other operation).
---
data/db/sqlite-stored-procs.sql | 2 +-
src/libtracker-data/tracker-data-query.c | 31 ++++++++++---
src/libtracker-data/tracker-data-query.h | 3 +-
src/tracker-indexer/tracker-indexer.c | 75 +++++++++++++++++++++--------
4 files changed, 81 insertions(+), 30 deletions(-)
diff --git a/data/db/sqlite-stored-procs.sql b/data/db/sqlite-stored-procs.sql
index 6b97bd9..446b375 100644
--- a/data/db/sqlite-stored-procs.sql
+++ b/data/db/sqlite-stored-procs.sql
@@ -46,7 +46,7 @@ DeleteServiceMetadata DELETE FROM ServiceMetaData WHERE ServiceID = ?;
DeleteServiceKeywordMetadata DELETE FROM ServiceMetaData WHERE ServiceID = ?;
DeleteServiceNumericMetadata DELETE FROM ServiceMetaData WHERE ServiceID = ?;
-GetServiceID SELECT ID, IndexTime, IsDirectory, ServiceTypeID FROM Services WHERE Path = ? AND Name = ?;
+GetServiceID SELECT ID, IndexTime, IsDirectory, ServiceTypeID, Enabled FROM Services WHERE Path = ? AND Name = ?;
GetByServiceType SELECT DISTINCT S.Path || '/' || S.Name AS uri FROM Services AS S WHERE S.Enabled = 1 AND (S.AuxilaryID = 0 OR S.AuxilaryID IN (SELECT VolumeID FROM Volumes WHERE Enabled = 1)) AND S.ServiceTypeID IN (SELECT TypeId FROM ServiceTypes WHERE TypeName = ? OR Parent = ?) LIMIT ?,?;
GetContents SELECT uncompress (Content) FROM ServiceContents WHERE ServiceID = ? AND MetadataID = ? AND Content is not null;
GetFileContents SELECT substr(uncompress (Content), ?, ?) FROM ServiceContents WHERE ServiceID = ?;
diff --git a/src/libtracker-data/tracker-data-query.c b/src/libtracker-data/tracker-data-query.c
index 895db97..b88daca 100644
--- a/src/libtracker-data/tracker-data-query.c
+++ b/src/libtracker-data/tracker-data-query.c
@@ -267,6 +267,7 @@ tracker_data_query_file_id (const gchar *service_type,
TrackerDBInterface *iface;
gchar *dir, *name;
guint32 id = 0;
+ gboolean enabled;
g_return_val_if_fail (path != NULL, 0);
@@ -290,8 +291,15 @@ tracker_data_query_file_id (const gchar *service_type,
g_free (name);
if (result_set) {
- tracker_db_result_set_get (result_set, 0, &id, -1);
+ tracker_db_result_set_get (result_set,
+ 0, &id,
+ 4, &enabled,
+ -1);
g_object_unref (result_set);
+
+ if (!enabled) {
+ id = 0;
+ }
}
return id;
@@ -319,13 +327,13 @@ tracker_data_query_service_exists (TrackerService *service,
const gchar *dirname,
const gchar *basename,
guint32 *service_id,
- time_t *mtime)
+ time_t *mtime,
+ gboolean *enabled)
{
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
- guint db_id;
- guint db_mtime;
- gboolean found = FALSE;
+ guint db_id, db_mtime;
+ gboolean db_enabled, found = FALSE;
db_id = db_mtime = 0;
@@ -341,6 +349,7 @@ tracker_data_query_service_exists (TrackerService *service,
tracker_db_result_set_get (result_set,
0, &db_id,
1, &db_mtime,
+ 4, &db_enabled,
-1);
g_object_unref (result_set);
found = TRUE;
@@ -354,6 +363,10 @@ tracker_data_query_service_exists (TrackerService *service,
*mtime = (time_t) db_mtime;
}
+ if (enabled) {
+ *enabled = db_enabled;
+ }
+
return found;
}
@@ -364,6 +377,7 @@ tracker_data_query_service_type_id (const gchar *dirname,
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
guint service_type_id;
+ gboolean enabled;
/* We are asking this because the module cannot assign service_type -> probably it is files */
iface = tracker_db_manager_get_db_interface_by_type ("Files",
@@ -378,10 +392,13 @@ tracker_data_query_service_type_id (const gchar *dirname,
return 0;
}
- tracker_db_result_set_get (result_set, 3, &service_type_id, -1);
+ tracker_db_result_set_get (result_set,
+ 3, &service_type_id,
+ 4, &enabled,
+ -1);
g_object_unref (result_set);
- return service_type_id;
+ return (enabled) ? service_type_id : 0;
}
GHashTable *
diff --git a/src/libtracker-data/tracker-data-query.h b/src/libtracker-data/tracker-data-query.h
index 9ad009e..2641d52 100644
--- a/src/libtracker-data/tracker-data-query.h
+++ b/src/libtracker-data/tracker-data-query.h
@@ -67,7 +67,8 @@ gboolean tracker_data_query_service_exists (TrackerService
const gchar *dirname,
const gchar *basename,
guint32 *service_id,
- time_t *mtime);
+ time_t *mtime,
+ gboolean *enabled);
guint tracker_data_query_service_type_id (const gchar *dirname,
const gchar *basename);
GHashTable * tracker_data_query_service_children (TrackerService *service,
diff --git a/src/tracker-indexer/tracker-indexer.c b/src/tracker-indexer/tracker-indexer.c
index f6d0812..7c5727a 100644
--- a/src/tracker-indexer/tracker-indexer.c
+++ b/src/tracker-indexer/tracker-indexer.c
@@ -214,6 +214,10 @@ static void state_check (TrackerIndexer *indexer);
static void check_finished (TrackerIndexer *indexer,
gboolean interrupted);
+static void item_erase (TrackerIndexer *indexer,
+ TrackerService *service,
+ guint32 service_id);
+
static gboolean item_process (TrackerIndexer *indexer,
PathInfo *info,
const gchar *dirname,
@@ -1599,6 +1603,7 @@ item_add_or_update (TrackerIndexer *indexer,
guint32 id;
gchar *mount_point = NULL;
gchar *service_path;
+ gboolean exists, enabled;
service = get_service_for_file (info->module_file, info->module);
@@ -1606,7 +1611,15 @@ item_add_or_update (TrackerIndexer *indexer,
return;
}
- if (tracker_data_query_service_exists (service, dirname, basename, &id, NULL)) {
+ exists = tracker_data_query_service_exists (service, dirname, basename, &id, NULL, &enabled);
+
+ if (exists && !enabled) {
+ /* Service must be deleted before insertion */
+ item_erase (indexer, service, id);
+ exists = FALSE;
+ }
+
+ if (exists) {
TrackerDataMetadata *old_metadata_emb, *old_metadata_non_emb;
gchar *old_text;
@@ -1949,6 +1962,7 @@ item_move (TrackerIndexer *indexer,
gchar *dest_dirname, *dest_basename;
guint32 service_id, dest_service_id;
GHashTable *children = NULL;
+ gboolean exists, enabled;
service = get_service_for_file (info->module_file, info->module);
@@ -1962,11 +1976,14 @@ item_move (TrackerIndexer *indexer,
g_debug ("Moving item from '%s' to '%s'", source_path, path);
/* Get 'source' ID */
- if (!tracker_data_query_service_exists (service,
- dirname,
- basename,
- &service_id,
- NULL)) {
+ exists = tracker_data_query_service_exists (service,
+ dirname,
+ basename,
+ &service_id,
+ NULL,
+ &enabled);
+
+ if (!exists || !enabled) {
gchar *dest_dirname, *dest_basename;
gboolean res;
@@ -1990,7 +2007,7 @@ item_move (TrackerIndexer *indexer,
dest_dirname,
dest_basename,
&dest_service_id,
- NULL)) {
+ NULL, NULL)) {
g_message ("Destination file '%s' already existed in database, removing", path);
/* Item has to be deleted from the database immediately */
@@ -2075,6 +2092,7 @@ item_mark_for_removal (TrackerIndexer *indexer,
const gchar *service_type;
guint service_id, service_type_id;
GHashTable *children = NULL;
+ gboolean exists, enabled;
g_debug ("Removing item: '%s/%s' (no metadata was given by module)",
dirname,
@@ -2093,9 +2111,9 @@ item_mark_for_removal (TrackerIndexer *indexer,
service_type = tracker_ontology_get_service_by_id (service_type_id);
service = tracker_ontology_get_service_by_name (service_type);
- tracker_data_query_service_exists (service, dirname, basename, &service_id, NULL);
+ exists = tracker_data_query_service_exists (service, dirname, basename, &service_id, NULL, &enabled);
- if (service_id < 1) {
+ if (!exists || !enabled) {
g_debug (" File does not exist anyway "
"(dirname:'%s', basename:'%s')",
dirname, basename);
@@ -2208,6 +2226,7 @@ handle_metadata_add (TrackerIndexer *indexer,
gchar *joined, *dirname = NULL, *basename = NULL;
gchar **old_contents;
gint len;
+ gboolean exists, enabled;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -2247,15 +2266,16 @@ handle_metadata_add (TrackerIndexer *indexer,
tracker_file_get_path_and_name (uri, &dirname, &basename);
- tracker_data_query_service_exists (service,
- dirname,
- basename,
- &service_id,
- NULL);
+ exists = tracker_data_query_service_exists (service,
+ dirname,
+ basename,
+ &service_id,
+ NULL,
+ &enabled);
g_free (dirname);
g_free (basename);
- if (service_id < 1) {
+ if (!exists || !enabled) {
g_set_error (error,
g_quark_from_string (TRACKER_INDEXER_ERROR),
TRACKER_INDEXER_ERROR_CODE,
@@ -2347,6 +2367,7 @@ handle_metadata_remove (TrackerIndexer *indexer,
TrackerField *field;
guint service_id, i;
gchar *joined = NULL, *dirname = NULL, *basename = NULL;
+ gboolean exists, enabled;
check_started (indexer);
@@ -2381,12 +2402,14 @@ handle_metadata_remove (TrackerIndexer *indexer,
tracker_file_get_path_and_name (uri, &dirname, &basename);
- tracker_data_query_service_exists (service, dirname, basename, &service_id, NULL);
+ exists = tracker_data_query_service_exists (service,
+ dirname, basename,
+ &service_id, NULL, &enabled);
g_free (dirname);
g_free (basename);
- if (service_id < 1) {
+ if (!exists || !enabled) {
g_set_error (error,
g_quark_from_string (TRACKER_INDEXER_ERROR),
TRACKER_INDEXER_ERROR_CODE,
@@ -2445,14 +2468,15 @@ handle_metadata_remove (TrackerIndexer *indexer,
static gboolean
should_change_index_for_file (TrackerIndexer *indexer,
- PathInfo *info,
- const gchar *dirname,
- const gchar *basename)
+ PathInfo *info,
+ const gchar *dirname,
+ const gchar *basename)
{
TrackerService *service;
gchar *path;
guint64 current_mtime;
time_t db_mtime;
+ gboolean enabled;
service = get_service_for_file (info->module_file, info->module);
@@ -2467,7 +2491,16 @@ should_change_index_for_file (TrackerIndexer *indexer,
dirname,
basename,
NULL,
- &db_mtime)) {
+ &db_mtime,
+ &enabled)) {
+ return TRUE;
+ }
+
+ /* Service exists, but is disabled. In this case
+ * we want to reindex, so the item will be deleted
+ * afterwards before inserting the new data.
+ */
+ if (!enabled) {
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]