tracker r2613 - in branches/turtle: . src/libtracker-common src/libtracker-data src/tracker-indexer src/trackerd
- From: pvanhoof svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2613 - in branches/turtle: . src/libtracker-common src/libtracker-data src/tracker-indexer src/trackerd
- Date: Fri, 28 Nov 2008 16:11:29 +0000 (UTC)
Author: pvanhoof
Date: Fri Nov 28 16:11:28 2008
New Revision: 2613
URL: http://svn.gnome.org/viewvc/tracker?rev=2613&view=rev
Log:
2008-11-28 Philip Van Hoof <philip codeminded be>
* src/libtracker-data/tracker-data-update.c
* src/libtracker-data/tracker-data-update.h
* src/tracker-indexer/tracker-removable-device.c: Making it actually work
* src/trackerd/tracker-backup.c: Fixed API of tracker_turtle_process,
base_uri
* src/libtracker-data/tracker-turtle.c
* src/libtracker-data/tracker-turtle.h
* src/libtracker-common/tracker-hal.c: Fixed that the dir of the mount-
point itself is not detected as "on the device"
Modified:
branches/turtle/ChangeLog
branches/turtle/src/libtracker-common/tracker-hal.c
branches/turtle/src/libtracker-data/tracker-data-update.c
branches/turtle/src/libtracker-data/tracker-data-update.h
branches/turtle/src/libtracker-data/tracker-turtle.c
branches/turtle/src/libtracker-data/tracker-turtle.h
branches/turtle/src/tracker-indexer/tracker-removable-device.c
branches/turtle/src/trackerd/tracker-backup.c
Modified: branches/turtle/src/libtracker-common/tracker-hal.c
==============================================================================
--- branches/turtle/src/libtracker-common/tracker-hal.c (original)
+++ branches/turtle/src/libtracker-common/tracker-hal.c Fri Nov 28 16:11:28 2008
@@ -1160,6 +1160,9 @@
g_return_val_if_fail (TRACKER_IS_HAL (hal), FALSE);
+ if (!path)
+ return FALSE;
+
priv = GET_PRIV (hal);
g_hash_table_iter_init (&iter, priv->removable_devices);
@@ -1182,7 +1185,7 @@
mp = libhal_volume_get_mount_point (volume);
- if (strcmp (mp, path) != 0) {
+ if (mp && strcmp (mp, path) != 0) {
if (g_strrstr (path, mp)) {
found = TRUE;
Modified: branches/turtle/src/libtracker-data/tracker-data-update.c
==============================================================================
--- branches/turtle/src/libtracker-data/tracker-data-update.c (original)
+++ branches/turtle/src/libtracker-data/tracker-data-update.c Fri Nov 28 16:11:28 2008
@@ -681,6 +681,29 @@
}
+static TrackerConfig *config = NULL;
+static TrackerLanguage *language = NULL;
+
+
+void
+tracker_data_start_turtle_import (void)
+{
+ if (!config)
+ config = tracker_config_new ();
+ if (!language)
+ language = tracker_language_new (config);
+}
+
+void
+tracker_data_stop_turtle_import (void)
+{
+ g_object_unref (language);
+ g_object_unref (config);
+ language = NULL;
+ config = NULL;
+}
+
+
/* TODO: URI branch path -> uri */
void
@@ -694,6 +717,8 @@
GError *error = NULL;
TrackerService *service;
gchar *escaped_path;
+ gchar *dirname;
+ const gchar *basename;
/* TODO untested and unfinished port that came from the decomposed
* branch of JÃrg. When merging from the decomposed branch to trunk
@@ -715,14 +740,18 @@
escaped_path = tracker_escape_string (path);
+ basename = g_basename (escaped_path);
+ dirname = g_dirname (escaped_path);
+
/* TODO Warning: comparing Modified against Accessed. Do we have a
* better field for this? */
result_set = tracker_db_interface_execute_query (iface, &error,
"SELECT ID, Accessed < '%s' FROM Services "
- "WHERE Path = '%s'",
+ "WHERE Path = '%s' AND "
+ "Name = '%s'",
modified,
- escaped_path);
+ dirname, basename);
if (error) {
#ifdef TURTLE_DEBUG
@@ -747,15 +776,17 @@
info->service = service;
info->iid_value = iid_value;
- info->config = tracker_config_new ();
- info->language = tracker_language_new (info->config);
+ info->config = config?g_object_ref (config):NULL;
+ info->language = language?g_object_ref (language):NULL;
tracker_data_metadata_foreach (metadata,
foreach_in_metadata_set_metadata,
info);
- g_object_unref (info->language);
- g_object_unref (info->config);
+ if (info->language)
+ g_object_unref (info->language);
+ if (info->config)
+ g_object_unref (info->config);
g_slice_free (ForeachInMetadataInfo, info);
}
@@ -766,15 +797,10 @@
g_object_unref (result_set);
} else {
- gchar *dirname;
- const gchar *basename;
guint32 id;
id = tracker_data_update_get_new_service_id (iface);
- basename = g_basename (path);
- dirname = g_dirname (path);
-
if (tracker_data_update_create_service (service, id,
dirname, basename,
metadata)) {
@@ -785,20 +811,23 @@
info->service = service;
info->iid_value = id;
- info->config = tracker_config_new ();
- info->language = tracker_language_new (info->config);
+ info->config = config?g_object_ref (config):NULL;
+ info->language = language?g_object_ref (language):NULL;
tracker_data_metadata_foreach (metadata,
foreach_in_metadata_set_metadata,
info);
- g_object_unref (info->language);
- g_object_unref (info->config);
+ if (info->language)
+ g_object_unref (info->language);
+ if (info->config)
+ g_object_unref (info->config);
g_slice_free (ForeachInMetadataInfo, info);
}
}
+ g_free (dirname);
g_free (escaped_path);
}
Modified: branches/turtle/src/libtracker-data/tracker-data-update.h
==============================================================================
--- branches/turtle/src/libtracker-data/tracker-data-update.h (original)
+++ branches/turtle/src/libtracker-data/tracker-data-update.h Fri Nov 28 16:11:28 2008
@@ -58,6 +58,8 @@
TrackerDataMetadata *metadata);
void tracker_data_delete_service (const gchar *path,
const gchar *rdf_type);
+void tracker_data_start_turtle_import (void);
+void tracker_data_stop_turtle_import (void);
/* Metadata */
void tracker_data_update_set_metadata (TrackerService *service,
Modified: branches/turtle/src/libtracker-data/tracker-turtle.c
==============================================================================
--- branches/turtle/src/libtracker-data/tracker-turtle.c (original)
+++ branches/turtle/src/libtracker-data/tracker-turtle.c Fri Nov 28 16:11:28 2008
@@ -316,12 +316,13 @@
void
tracker_turtle_process (const gchar *turtle_file,
+ const gchar *base_uri,
TurtleTripleCallback callback,
void *user_data)
{
#ifdef HAVE_RAPTOR
unsigned char *uri_string;
- raptor_uri *uri;
+ raptor_uri *uri, *buri;
raptor_parser *parser;
#endif
if (!initialized) {
@@ -339,11 +340,13 @@
uri_string = raptor_uri_filename_to_uri_string (turtle_file);
uri = raptor_new_uri (uri_string);
+ buri = raptor_new_uri (base_uri);
- raptor_parse_file (parser, uri, uri);
+ raptor_parse_file (parser, uri, buri);
raptor_free_uri (uri);
raptor_free_memory (uri_string);
+ raptor_free_uri (buri);
raptor_free_parser (parser);
@@ -357,7 +360,7 @@
#ifdef HAVE_RAPTOR
raptor_uri *suri;
TurtleOptimizerInfo *info;
- gchar *tmp_file;
+ gchar *tmp_file, *base_uri;
FILE *target_file;
#endif
@@ -383,10 +386,14 @@
info->serializer = raptor_new_serializer ("turtle");
suri = raptor_new_uri ("/");
+ base_uri = g_strdup_printf ("file://%s", turtle_file);
+
raptor_serialize_start_to_file_handle (info->serializer,
suri, target_file);
- tracker_turtle_process (turtle_file, consume_triple_optimizer, info);
+ tracker_turtle_process (turtle_file, base_uri, consume_triple_optimizer, info);
+
+ g_free (base_uri);
/* Commit final subject (or loop doesn't handle the very last) */
commit_turtle_parse_info_optimizer (info);
Modified: branches/turtle/src/libtracker-data/tracker-turtle.h
==============================================================================
--- branches/turtle/src/libtracker-data/tracker-turtle.h (original)
+++ branches/turtle/src/libtracker-data/tracker-turtle.h Fri Nov 28 16:11:28 2008
@@ -68,6 +68,7 @@
/* Reading functions */
void tracker_turtle_process (const gchar *turtle_file,
+ const gchar *base_uri,
TurtleTripleCallback callback,
void *user_data);
Modified: branches/turtle/src/tracker-indexer/tracker-removable-device.c
==============================================================================
--- branches/turtle/src/tracker-indexer/tracker-removable-device.c (original)
+++ branches/turtle/src/tracker-indexer/tracker-removable-device.c Fri Nov 28 16:11:28 2008
@@ -268,7 +268,7 @@
if (g_file_test (file, G_FILE_TEST_EXISTS)) {
static gboolean has_init = FALSE;
TurtleStorerInfo *info;
- gchar *copy_file, *ptr;
+ gchar *copy_file, *ptr, *base_uri;
info = g_slice_new0 (TurtleStorerInfo);
@@ -276,25 +276,18 @@
info->indexer = g_object_ref (indexer);
info->amount = 0;
- copy_file = g_strdup (file);
-
- ptr = strstr (copy_file, "/metadata/metadata.ttl");
- /* .cache remains, and will be cut later, just like dummy_file is */
- *ptr = '\0';
-
- /* Take the file (dummy_file or .cache) from base */
- ptr = strrchr (copy_file, '/');
- if (ptr)
- *ptr = '\0';
-
- info->base = copy_file;
+ info->base = g_strdup (mount_point);
/* We need to open the transaction, during the parsing will the
* transaction be committed and reopened */
tracker_indexer_open_transaction (info->indexer);
- tracker_turtle_process (file, consume_triple_storer, info);
+ tracker_data_start_turtle_import ();
+
+ base_uri = g_strdup_printf ("file://%s/", mount_point);
+ tracker_turtle_process (file, base_uri, consume_triple_storer, info);
+ g_free (base_uri);
/* Commit final subject (our loop doesn't handle the very last)
* It can't be a REMOVAL nor MOVE as those happen immediately. */
@@ -305,9 +298,11 @@
/* We will (always) be left in open state, so we commit the
* last opened transaction */
+ tracker_data_stop_turtle_import ();
+
tracker_indexer_commit_transaction (info->indexer);
- g_free (copy_file);
+ g_free (info->base);
g_object_unref (info->indexer);
g_slice_free (TurtleStorerInfo, info);
}
Modified: branches/turtle/src/trackerd/tracker-backup.c
==============================================================================
--- branches/turtle/src/trackerd/tracker-backup.c (original)
+++ branches/turtle/src/trackerd/tracker-backup.c Fri Nov 28 16:11:28 2008
@@ -118,8 +118,10 @@
void
tracker_backup_restore ()
{
+ gchar *base_uri;
g_message ("***** Restoring metadata from turtle file *****");
-
- tracker_turtle_process (TODO_TEMPORARY_LOCATION, loading_turtle, NULL);
+ base_uri = g_strdup_printf ("file://%s", TODO_TEMPORARY_LOCATION);
+ tracker_turtle_process (TODO_TEMPORARY_LOCATION, base_uri, loading_turtle, NULL);
+ g_free (base_uri);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]