tracker r2075 - in branches/indexer-split: . data data/dbus src/libtracker-common src/libtracker-db src/tracker-indexer
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2075 - in branches/indexer-split: . data data/dbus src/libtracker-common src/libtracker-db src/tracker-indexer
- Date: Thu, 14 Aug 2008 16:14:13 +0000 (UTC)
Author: carlosg
Date: Thu Aug 14 16:14:13 2008
New Revision: 2075
URL: http://svn.gnome.org/viewvc/tracker?rev=2075&view=rev
Log:
2008-08-14 Carlos Garnacho <carlos imendio com>
Add FileMove DBus method to tracker-indexer.
* data/dbus/tracker-indexer.xml: Define new method.
* data/sqlite-stored-procs.sql: Add MoveService and
MoveServiceChildren, stored procedures that actually switch paths in
the DB.
* src/libtracker-common/tracker-utils.[ch] (tracker_string_replace):
Misc fix, that function should take const strings.
* src/libtracker-db/tracker-db-manager.c (function_replace): Add a SQL
function to replace a substring with other.
* src/tracker-indexer/tracker-indexer-db.[ch]
(tracker_db_move_service):
* src/tracker-indexer/tracker-indexer.[ch]
(tracker_indexer_file_move): Implement moving files in
tracker-indexer.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/data/dbus/tracker-indexer.xml
branches/indexer-split/data/sqlite-stored-procs.sql
branches/indexer-split/src/libtracker-common/tracker-utils.c
branches/indexer-split/src/libtracker-common/tracker-utils.h
branches/indexer-split/src/libtracker-db/tracker-db-manager.c
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
branches/indexer-split/src/tracker-indexer/tracker-indexer.h
Modified: branches/indexer-split/data/dbus/tracker-indexer.xml
==============================================================================
--- branches/indexer-split/data/dbus/tracker-indexer.xml (original)
+++ branches/indexer-split/data/dbus/tracker-indexer.xml Thu Aug 14 16:14:13 2008
@@ -26,6 +26,12 @@
<arg type="s" name="module" direction="in" />
<arg type="as" name="files" direction="in" />
</method>
+ <method name="FileMove">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="s" name="module" direction="in" />
+ <arg type="s" name="file_from" direction="in" />
+ <arg type="s" name="file_to" direction="in" />
+ </method>
<method name="PropertySet">
<annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
Modified: branches/indexer-split/data/sqlite-stored-procs.sql
==============================================================================
--- branches/indexer-split/data/sqlite-stored-procs.sql (original)
+++ branches/indexer-split/data/sqlite-stored-procs.sql Thu Aug 14 16:14:13 2008
@@ -48,6 +48,8 @@
CreateService INSERT INTO Services (ID, Path, Name, ServiceTypeID, Mime, Size, IsDirectory, IsLink, Offset, IndexTime, AuxilaryID) VALUES (?,?,?,?,?,?,?,?,?,?,?);
+MoveService UPDATE Services SET Path = ?, Name = ? WHERE Path = ? AND Name = ?;
+MoveServiceChildren UPDATE Services SET Path = replace (Path, ?, ?);
GetServiceID SELECT ID, IndexTime, IsDirectory, ServiceTypeID FROM Services WHERE Path = ? AND Name = ?;
@@ -76,7 +78,6 @@
DeleteService10 Delete FROM ServiceLinks Where (DestPath = ?) or (DestPath glob ?);
DeleteService11 DELETE FROM ServiceContents where ServiceID = ?;
-
DeleteServiceMetadata DELETE FROM ServiceMetaData WHERE ServiceID = ?;
DeleteServiceKeywordMetadata DELETE FROM ServiceMetaData WHERE ServiceID = ?;
DeleteServiceNumericMetadata DELETE FROM ServiceMetaData WHERE ServiceID = ?;
Modified: branches/indexer-split/src/libtracker-common/tracker-utils.c
==============================================================================
--- branches/indexer-split/src/libtracker-common/tracker-utils.c (original)
+++ branches/indexer-split/src/libtracker-common/tracker-utils.c Thu Aug 14 16:14:13 2008
@@ -71,9 +71,9 @@
}
gchar *
-tracker_string_replace (const gchar *haystack,
- gchar *needle,
- gchar *replacement)
+tracker_string_replace (const gchar *haystack,
+ const gchar *needle,
+ const gchar *replacement)
{
GString *str;
gint pos, needle_len;
@@ -85,6 +85,7 @@
str = g_string_new ("");
+ /* FIXME: should use strstr */
for (pos = 0; haystack[pos]; pos++) {
if (strncmp (&haystack[pos], needle, needle_len) == 0) {
if (replacement) {
Modified: branches/indexer-split/src/libtracker-common/tracker-utils.h
==============================================================================
--- branches/indexer-split/src/libtracker-common/tracker-utils.h (original)
+++ branches/indexer-split/src/libtracker-common/tracker-utils.h Thu Aug 14 16:14:13 2008
@@ -28,8 +28,8 @@
gboolean tracker_is_empty_string (const char *str);
gchar * tracker_string_replace (const gchar *haystack,
- gchar *needle,
- gchar *replacement);
+ const gchar *needle,
+ const gchar *replacement);
gchar * tracker_string_remove (gchar *haystack,
const gchar *needle);
gchar * tracker_escape_string (const gchar *in);
Modified: branches/indexer-split/src/libtracker-db/tracker-db-manager.c
==============================================================================
--- branches/indexer-split/src/libtracker-db/tracker-db-manager.c (original)
+++ branches/indexer-split/src/libtracker-db/tracker-db-manager.c Thu Aug 14 16:14:13 2008
@@ -1472,6 +1472,24 @@
return result;
}
+static GValue
+function_replace (TrackerDBInterface *interface,
+ gint argc,
+ GValue values[])
+{
+ GValue result = { 0, };
+ gchar *str;
+
+ str = tracker_string_replace (g_value_get_string (&values[0]),
+ g_value_get_string (&values[1]),
+ g_value_get_string (&values[2]));
+
+ g_value_init (&result, G_TYPE_STRING);
+ g_value_take_string (&result, str);
+
+ return result;
+}
+
static void
db_set_params (TrackerDBInterface *iface,
gint cache_size,
@@ -1531,7 +1549,10 @@
"compress",
function_compress,
1);
-
+ tracker_db_interface_sqlite_create_function (iface,
+ "replace",
+ function_replace,
+ 3);
}
}
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 Thu Aug 14 16:14:13 2008
@@ -328,6 +328,32 @@
}
void
+tracker_db_move_service (TrackerService *service,
+ const gchar *from,
+ const gchar *to)
+{
+ TrackerDBInterface *iface;
+ GError *error = NULL;
+ gchar *from_dirname, *from_basename, *to_dirname, *to_basename;
+
+ iface = tracker_db_manager_get_db_interface_by_type (tracker_service_get_name (service),
+ TRACKER_DB_CONTENT_TYPE_METADATA);
+
+ from_dirname = tracker_file_get_vfs_path (from);
+ from_basename = tracker_file_get_vfs_name (from);
+ to_dirname = tracker_file_get_vfs_path (to);
+ to_basename = tracker_file_get_vfs_name (to);
+
+ tracker_db_interface_execute_procedure (iface, NULL, "MoveService",
+ from_dirname, from_basename,
+ to_dirname, to_basename,
+ NULL);
+
+ /* FIXME: This procedure should use LIKE statement */
+ tracker_db_interface_execute_procedure (iface, &error, "MoveServiceChildren", from, to, from, NULL);
+}
+
+void
tracker_db_delete_all_metadata (TrackerService *service,
guint32 service_id)
{
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 Thu Aug 14 16:14:13 2008
@@ -48,6 +48,9 @@
void tracker_db_delete_service (TrackerService *service,
guint32 id);
+void tracker_db_move_service (TrackerService *service,
+ const gchar *from,
+ const gchar *to);
/* Metadata */
void tracker_db_set_metadata (TrackerService *service,
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 Thu Aug 14 16:14:13 2008
@@ -1935,6 +1935,58 @@
}
void
+tracker_indexer_file_move (TrackerIndexer *indexer,
+ const gchar *module_name,
+ gchar *from,
+ gchar *to,
+ DBusGMethodInvocation *context,
+ GError **error)
+{
+ GModule *module;
+ TrackerService *service;
+ gchar *service_type;
+ guint request_id;
+ GError *actual_error;
+ PathInfo *info;
+
+ tracker_dbus_async_return_if_fail (TRACKER_IS_INDEXER (indexer), FALSE);
+ tracker_dbus_async_return_if_fail (from != NULL, FALSE);
+ tracker_dbus_async_return_if_fail (to != NULL, FALSE);
+
+ request_id = tracker_dbus_get_next_request_id ();
+
+ tracker_dbus_request_new (request_id,
+ "DBus request to move '%s' to '%s'",
+ from, to);
+
+ module = g_hash_table_lookup (indexer->private->indexer_modules, module_name);
+
+ if (!module) {
+ tracker_dbus_request_failed (request_id,
+ &actual_error,
+ "The module '%s' is not loaded",
+ module_name);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
+ }
+
+ /* FIXME: This should be probably queued up somewhere */
+ info = path_info_new (module, module_name, to);
+
+ service_type = tracker_indexer_module_file_get_service_type (module, info->file);
+ service = tracker_ontology_get_service_type_by_name (service_type);
+ g_free (service_type);
+
+ tracker_db_move_service (service, from, to);
+
+ dbus_g_method_return (context);
+ tracker_dbus_request_success (request_id);
+
+ path_info_free (info);
+}
+
+void
tracker_indexer_property_set (TrackerIndexer *indexer,
const gchar *service_type,
const gchar *uri,
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.h (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.h Thu Aug 14 16:14:13 2008
@@ -105,6 +105,12 @@
GStrv files,
DBusGMethodInvocation *context,
GError **error);
+void tracker_indexer_file_move (TrackerIndexer *indexer,
+ const gchar *module_name,
+ gchar *from,
+ gchar *to,
+ DBusGMethodInvocation *context,
+ GError **error);
void tracker_indexer_property_set (TrackerIndexer *indexer,
const gchar *service_type,
const gchar *uri,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]