tracker r2508 - in branches/uri: . src/libtracker-data src/tracker-indexer
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2508 - in branches/uri: . src/libtracker-data src/tracker-indexer
- Date: Mon, 17 Nov 2008 15:21:13 +0000 (UTC)
Author: juergbi
Date: Mon Nov 17 15:21:13 2008
New Revision: 2508
URL: http://svn.gnome.org/viewvc/tracker?rev=2508&view=rev
Log:
2008-11-17 JÃrg Billeter <j bitron ch>
* src/libtracker-data/tracker-data-query.c:
* src/libtracker-data/tracker-data-query.h:
* src/libtracker-data/tracker-data-update.c:
* src/libtracker-data/tracker-data-update.h:
* src/tracker-indexer/tracker-indexer.c:
Convert tracker_data_query_service_exists,
tracker_data_query_service_type_id, and
tracker_data_update_create_service
from dirname and basename to URI
Modified:
branches/uri/ChangeLog
branches/uri/src/libtracker-data/tracker-data-query.c
branches/uri/src/libtracker-data/tracker-data-query.h
branches/uri/src/libtracker-data/tracker-data-update.c
branches/uri/src/libtracker-data/tracker-data-update.h
branches/uri/src/tracker-indexer/tracker-indexer.c
Modified: branches/uri/src/libtracker-data/tracker-data-query.c
==============================================================================
--- branches/uri/src/libtracker-data/tracker-data-query.c (original)
+++ branches/uri/src/libtracker-data/tracker-data-query.c Mon Nov 17 15:21:13 2008
@@ -299,14 +299,12 @@
gboolean
tracker_data_query_service_exists (TrackerService *service,
- const gchar *dirname,
- const gchar *basename,
+ const gchar *uri,
guint32 *service_id,
time_t *mtime)
{
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
- gchar *path;
gchar *db_mtime_str;
guint db_id;
guint db_mtime;
@@ -314,14 +312,12 @@
db_id = db_mtime = 0;
- path = g_build_path (G_DIR_SEPARATOR_S, dirname, basename, NULL);
-
iface = tracker_db_manager_get_db_interface_by_type (tracker_service_get_name (service),
TRACKER_DB_CONTENT_TYPE_METADATA);
result_set = tracker_db_interface_execute_procedure (iface, NULL,
"GetServiceID",
- path,
+ uri,
NULL);
if (result_set) {
tracker_db_result_set_get (result_set,
@@ -349,23 +345,19 @@
}
guint
-tracker_data_query_service_type_id (const gchar *dirname,
- const gchar *basename)
+tracker_data_query_service_type_id (const gchar *uri)
{
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
- gchar *path;
guint service_type_id;
- path = g_build_path (G_DIR_SEPARATOR_S, dirname, basename, NULL);
-
/* 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",
TRACKER_DB_CONTENT_TYPE_METADATA);
result_set = tracker_db_interface_execute_procedure (iface, NULL,
"GetServiceID",
- path,
+ uri,
NULL);
if (!result_set) {
return 0;
Modified: branches/uri/src/libtracker-data/tracker-data-query.h
==============================================================================
--- branches/uri/src/libtracker-data/tracker-data-query.h (original)
+++ branches/uri/src/libtracker-data/tracker-data-query.h Mon Nov 17 15:21:13 2008
@@ -62,12 +62,10 @@
/* Using path */
gboolean tracker_data_query_service_exists (TrackerService *service,
- const gchar *dirname,
- const gchar *basename,
+ const gchar *uri,
guint32 *service_id,
time_t *mtime);
-guint tracker_data_query_service_type_id (const gchar *dirname,
- const gchar *basename);
+guint tracker_data_query_service_type_id (const gchar *uri);
/* Service API */
gchar * tracker_data_query_service_type_by_id (TrackerDBInterface *iface,
Modified: branches/uri/src/libtracker-data/tracker-data-update.c
==============================================================================
--- branches/uri/src/libtracker-data/tracker-data-update.c (original)
+++ branches/uri/src/libtracker-data/tracker-data-update.c Mon Nov 17 15:21:13 2008
@@ -145,13 +145,12 @@
gboolean
tracker_data_update_create_service (TrackerService *service,
- guint32 service_id,
- const gchar *dirname,
- const gchar *basename,
+ guint32 service_id,
+ const gchar *uri,
TrackerDataMetadata *metadata)
{
TrackerDBInterface *iface;
- gchar *id_str, *service_type_id_str, *path;
+ gchar *id_str, *service_type_id_str, *basename;
gboolean is_dir, is_symlink, enabled;
if (!service) {
@@ -164,15 +163,15 @@
id_str = tracker_guint32_to_string (service_id);
service_type_id_str = tracker_gint_to_string (tracker_service_get_id (service));
- path = g_build_filename (dirname, basename, NULL);
+ basename = g_path_get_basename (uri);
- is_dir = g_file_test (path, G_FILE_TEST_IS_DIR);
- is_symlink = g_file_test (path, G_FILE_TEST_IS_SYMLINK);
+ is_dir = g_file_test (uri, G_FILE_TEST_IS_DIR);
+ is_symlink = g_file_test (uri, G_FILE_TEST_IS_SYMLINK);
/* FIXME: do not hardcode arguments */
tracker_db_interface_execute_procedure (iface, NULL, "CreateService",
id_str,
- path,
+ uri,
basename,
service_type_id_str,
is_dir ? "Folder" : tracker_data_metadata_lookup (metadata, "File:Mime"),
@@ -196,7 +195,7 @@
g_free (id_str);
g_free (service_type_id_str);
- g_free (path);
+ g_free (basename);
return TRUE;
}
@@ -229,7 +228,7 @@
void
tracker_data_update_delete_service_recursively (TrackerService *service,
- gchar *service_path)
+ const gchar *service_path)
{
TrackerDBInterface *iface;
gchar *str;
Modified: branches/uri/src/libtracker-data/tracker-data-update.h
==============================================================================
--- branches/uri/src/libtracker-data/tracker-data-update.h (original)
+++ branches/uri/src/libtracker-data/tracker-data-update.h Mon Nov 17 15:21:13 2008
@@ -41,13 +41,12 @@
/* Services */
gboolean tracker_data_update_create_service (TrackerService *service,
guint32 service_id,
- const gchar *dirname,
- const gchar *basename,
+ const gchar *uri,
TrackerDataMetadata *metadata);
void tracker_data_update_delete_service (TrackerService *service,
guint32 service_id);
void tracker_data_update_delete_service_recursively (TrackerService *service,
- gchar *service_path);
+ const gchar *service_path);
void tracker_data_update_move_service (TrackerService *service,
const gchar *from,
const gchar *to);
Modified: branches/uri/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/uri/src/tracker-indexer/tracker-indexer.c (original)
+++ branches/uri/src/tracker-indexer/tracker-indexer.c Mon Nov 17 15:21:13 2008
@@ -1294,8 +1294,7 @@
static void
item_add_or_update (TrackerIndexer *indexer,
PathInfo *info,
- const gchar *dirname,
- const gchar *basename,
+ const gchar *uri,
TrackerDataMetadata *metadata)
{
TrackerService *service;
@@ -1317,15 +1316,14 @@
return;
}
- if (tracker_data_query_service_exists (service, dirname, basename, &id, NULL)) {
+ if (tracker_data_query_service_exists (service, uri, &id, NULL)) {
TrackerDataMetadata *old_metadata;
gchar *old_text;
gchar *new_text;
/* Update case */
- g_debug ("Updating item '%s/%s'",
- dirname,
- basename);
+ g_debug ("Updating item '%s'",
+ uri);
/*
* Using DB directly: get old (embedded) metadata,
@@ -1349,17 +1347,15 @@
return;
}
- g_debug ("Adding item '%s/%s'",
- dirname,
- basename);
+ g_debug ("Adding item '%s'",
+ uri);
/* Service wasn't previously indexed */
id = tracker_data_update_get_new_service_id (indexer->private->common);
tracker_data_update_create_service (service,
id,
- dirname,
- basename,
+ uri,
metadata);
tracker_data_update_create_event (indexer->private->cache, id, "Create");
@@ -1386,8 +1382,7 @@
static void
item_move (TrackerIndexer *indexer,
PathInfo *info,
- const gchar *dirname,
- const gchar *basename)
+ const gchar *uri)
{
TrackerService *service;
TrackerDataMetadata *metadata;
@@ -1414,8 +1409,7 @@
/* Get 'source' ID */
if (!tracker_data_query_service_exists (service,
- dirname,
- basename,
+ uri,
&id,
NULL)) {
g_message ("Source file '%s' not found in database to move",
@@ -1439,20 +1433,17 @@
static void
item_remove (TrackerIndexer *indexer,
PathInfo *info,
- const gchar *dirname,
- const gchar *basename)
+ const gchar *uri)
{
TrackerService *service;
gchar *content, *metadata;
- gchar *service_path;
const gchar *service_type;
guint service_id, service_type_id;
service_type = tracker_module_config_get_index_service (info->module_name);
- g_debug ("Removing item: '%s/%s' (no metadata was given by module)",
- dirname,
- basename);
+ g_debug ("Removing item: '%s' (no metadata was given by module)",
+ uri);
if (!service_type || !service_type[0]) {
gchar *name;
@@ -1460,7 +1451,7 @@
/* The file is not anymore in the filesystem. Obtain
* the service type from the DB.
*/
- service_type_id = tracker_data_query_service_type_id (dirname, basename);
+ service_type_id = tracker_data_query_service_type_id (uri);
if (service_type_id == 0) {
/* File didn't exist, nothing to delete */
@@ -1475,12 +1466,12 @@
service_type_id = tracker_service_get_id (service);
}
- tracker_data_query_service_exists (service, dirname, basename, &service_id, NULL);
+ tracker_data_query_service_exists (service, uri, &service_id, NULL);
if (service_id < 1) {
g_debug (" File does not exist anyway "
- "(dirname:'%s', basename:'%s')",
- dirname, basename);
+ "(uri:'%s')",
+ uri);
return;
}
@@ -1519,18 +1510,11 @@
g_free (metadata);
/* Delete service */
- service_path = g_build_path (G_DIR_SEPARATOR_S,
- dirname,
- basename,
- NULL);
-
tracker_data_update_delete_service (service, service_id);
- tracker_data_update_delete_service_recursively (service, service_path);
+ tracker_data_update_delete_service_recursively (service, uri);
tracker_data_update_delete_all_metadata (service, service_id);
tracker_data_update_decrement_stats (indexer->private->common, service);
-
- g_free (service_path);
}
/*
@@ -1549,7 +1533,7 @@
TrackerField *field;
guint service_id, i, j = 0;
gchar **setted_values;
- gchar *joined, *dirname = NULL, *basename = NULL;
+ gchar *joined;
gchar **old_contents;
gint len;
@@ -1598,15 +1582,10 @@
return FALSE;
}
- tracker_file_get_path_and_name (uri, &dirname, &basename);
-
tracker_data_query_service_exists (service,
- dirname,
- basename,
+ uri,
&service_id,
NULL);
- g_free (dirname);
- g_free (basename);
if (service_id < 1) {
g_set_error (error,
@@ -1700,7 +1679,7 @@
TrackerService *service;
TrackerField *field;
guint service_id, i;
- gchar *joined = NULL, *dirname = NULL, *basename = NULL;
+ gchar *joined = NULL;
check_started (indexer);
@@ -1733,12 +1712,7 @@
return FALSE;
}
- tracker_file_get_path_and_name (uri, &dirname, &basename);
-
- tracker_data_query_service_exists (service, dirname, basename, &service_id, NULL);
-
- g_free (dirname);
- g_free (basename);
+ tracker_data_query_service_exists (service, uri, &service_id, NULL);
if (service_id < 1) {
g_set_error (error,
@@ -1800,12 +1774,11 @@
static gboolean
should_index_file (TrackerIndexer *indexer,
PathInfo *info,
- const gchar *dirname,
- const gchar *basename)
+ const gchar *uri)
{
TrackerService *service;
gchar *service_type;
- const gchar *str;
+ gchar *str;
gboolean is_dir;
gboolean should_be_cached;
struct stat st;
@@ -1828,8 +1801,7 @@
* definitely want to index it.
*/
if (!tracker_data_query_service_exists (service,
- dirname,
- basename,
+ uri,
NULL,
&mtime)) {
return TRUE;
@@ -1882,9 +1854,9 @@
* or not. All operations are done using the same string.
*/
if (is_dir) {
- str = info->file->path;
+ str = g_strdup (info->file->path);
} else {
- str = dirname;
+ str = g_path_get_basename (info->file->path);
}
/* Step 1. */
@@ -1906,50 +1878,41 @@
str,
should_index ? "should index" : "should not index");
+ g_free (str);
+
return should_index;
}
/* Step 2. */
if (!is_dir) {
- gchar *parent_dirname;
- gchar *parent_basename;
gboolean exists;
/* FIXME: What if there is no parent? */
- parent_dirname = g_path_get_dirname (dirname);
- parent_basename = g_path_get_basename (dirname);
/* We don't have the mtime for the dirname yet, we do
* if this is a info->file->path of course.
*/
exists = tracker_data_query_service_exists (service,
- parent_dirname,
- parent_basename,
+ str,
NULL,
&mtime);
if (!exists) {
- g_message ("Expected path '%s/%s' to exist, not in database?",
- parent_dirname,
- parent_basename);
+ g_message ("Expected path '%s' to exist, not in database?",
+ str);
- g_free (parent_basename);
- g_free (parent_dirname);
+ g_free (str);
return TRUE;
}
- if (g_lstat (dirname, &st) == -1) {
+ if (g_lstat (str, &st) == -1) {
g_message ("Expected path '%s' to exist, could not stat()",
- parent_dirname);
+ str);
- g_free (parent_basename);
- g_free (parent_dirname);
+ g_free (str);
return TRUE;
}
-
- g_free (parent_basename);
- g_free (parent_dirname);
}
if (st.st_mtime <= mtime) {
@@ -1957,6 +1920,8 @@
is_dir ? "Path" : "Parent path",
str);
+ g_free (str);
+
return FALSE;
}
@@ -1969,6 +1934,8 @@
g_strdup (str),
GINT_TO_POINTER (1));
+ g_free (str);
+
return TRUE;
}
static gboolean
@@ -1978,6 +1945,7 @@
TrackerDataMetadata *metadata;
gchar *dirname;
gchar *basename;
+ gchar *uri;
/* Note: If info->other_file is set, the PathInfo is for a
* MOVE event not for normal file event.
@@ -1993,6 +1961,8 @@
return !tracker_indexer_module_file_iter_contents (info->module, info->file);
}
+ uri = g_build_path (G_DIR_SEPARATOR_S, dirname, basename, NULL);
+
/*
* FIRST:
* ======
@@ -2017,7 +1987,7 @@
* email based dirname.
*/
if (G_LIKELY (!info->other_file) && dirname[0] == G_DIR_SEPARATOR) {
- if (!should_index_file (indexer, info, dirname, basename)) {
+ if (!should_index_file (indexer, info, uri)) {
g_debug ("File is already up to date: '%s'", info->file->path);
g_free (dirname);
@@ -2035,15 +2005,15 @@
* a service and set the metadata.
*/
if (G_UNLIKELY (info->other_file)) {
- item_move (indexer, info, dirname, basename);
+ item_move (indexer, info, uri);
} else {
metadata = tracker_indexer_module_file_get_metadata (info->module, info->file);
if (metadata) {
- item_add_or_update (indexer, info, dirname, basename, metadata);
+ item_add_or_update (indexer, info, uri, metadata);
tracker_data_metadata_free (metadata);
} else {
- item_remove (indexer, info, dirname, basename);
+ item_remove (indexer, info, uri);
}
}
@@ -2051,6 +2021,7 @@
g_free (dirname);
g_free (basename);
+ g_free (uri);
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]