tracker r2512 - in trunk: . data/db src/libtracker-data src/tracker-indexer
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2512 - in trunk: . data/db src/libtracker-data src/tracker-indexer
- Date: Tue, 18 Nov 2008 10:05:39 +0000 (UTC)
Author: juergbi
Date: Tue Nov 18 10:05:39 2008
New Revision: 2512
URL: http://svn.gnome.org/viewvc/tracker?rev=2512&view=rev
Log:
2008-11-18 JÃrg Billeter <j bitron ch>
* data/db/sqlite-stored-procs.sql: Add procedures to handle volumes
* src/libtracker-data/tracker-data-update.[ch]:
* src/tracker-indexer/tracker-indexer.c: Update Volumes table when
volume is added or removed, set AuxID in Services table to VolumeID
when inserting new entry
Modified:
trunk/ChangeLog
trunk/data/db/sqlite-stored-procs.sql
trunk/src/libtracker-data/tracker-data-update.c
trunk/src/libtracker-data/tracker-data-update.h
trunk/src/tracker-indexer/tracker-indexer.c
Modified: trunk/data/db/sqlite-stored-procs.sql
==============================================================================
--- trunk/data/db/sqlite-stored-procs.sql (original)
+++ trunk/data/db/sqlite-stored-procs.sql Tue Nov 18 10:05:39 2008
@@ -129,6 +129,16 @@
GetHitDetails SELECT ROWID, HitCount, HitArraySize FROM HitIndex WHERE word = ?;
/*
+ * Volume handling
+ */
+
+GetVolumeID SELECT VolumeID FROM Volumes WHERE UDI = ?;
+GetVolumeByPath SELECT VolumeID FROM Volumes WHERE Enabled = 1 AND (? = MountPath OR ? LIKE (MountPath || '/%'));
+InsertVolume INSERT INTO Volumes (MountPath, UDI, Enabled) VALUES (?, ?, 1);
+EnableVolume UPDATE Volumes SET MountPath = ?, Enabled = 1 WHERE UDI = ?;
+DisableVolume UPDATE Volumes SET Enabled = 0 WHERE UDI = ?;
+
+/*
* XESAM queries
*/
InsertXesamMetadataType INSERT INTO XesamMetaDataTypes (MetaName) VALUES (?);
Modified: trunk/src/libtracker-data/tracker-data-update.c
==============================================================================
--- trunk/src/libtracker-data/tracker-data-update.c (original)
+++ trunk/src/libtracker-data/tracker-data-update.c Tue Nov 18 10:05:39 2008
@@ -151,13 +151,28 @@
TrackerDataMetadata *metadata)
{
TrackerDBInterface *iface;
- gchar *id_str, *service_type_id_str, *path;
+ TrackerDBResultSet *result_set;
+ guint32 volume_id = 0;
+ gchar *id_str, *service_type_id_str, *path, *volume_id_str;
gboolean is_dir, is_symlink, enabled;
if (!service) {
return FALSE;
}
+ /* retrieve VolumeID */
+ iface = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
+ result_set = tracker_db_interface_execute_procedure (iface, NULL,
+ "GetVolumeByPath",
+ dirname,
+ dirname,
+ NULL);
+ if (result_set) {
+ tracker_db_result_set_get (result_set, 0, &volume_id, -1);
+ g_object_unref (result_set);
+ }
+ volume_id_str = tracker_guint32_to_string (volume_id);
+
iface = tracker_db_manager_get_db_interface_by_type (tracker_service_get_name (service),
TRACKER_DB_CONTENT_TYPE_METADATA);
@@ -181,7 +196,7 @@
is_symlink ? "1" : "0",
"0", /* Offset */
tracker_data_metadata_lookup (metadata, "File:Modified"),
- "0", /* Aux ID */
+ volume_id_str, /* Aux ID */
NULL);
enabled = is_dir ?
@@ -196,6 +211,7 @@
g_free (id_str);
g_free (service_type_id_str);
+ g_free (volume_id_str);
g_free (path);
return TRUE;
@@ -554,3 +570,57 @@
tracker_data_manager_exec (iface, "DELETE FROM Events WHERE BeingHandled = 1");
}
+void
+tracker_data_update_add_volume (const gchar *udi,
+ const gchar *mount_path)
+{
+ TrackerDBInterface *iface;
+ TrackerDBResultSet *result_set;
+ guint32 id = 0;
+
+ g_return_if_fail (udi != NULL);
+ g_return_if_fail (mount_path != NULL);
+
+ iface = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
+
+ result_set = tracker_db_interface_execute_procedure (iface, NULL,
+ "GetVolumeID",
+ udi,
+ NULL);
+
+
+ if (result_set) {
+ tracker_db_result_set_get (result_set, 0, &id, -1);
+ g_object_unref (result_set);
+ }
+
+ if (id == 0) {
+ tracker_db_interface_execute_procedure (iface, NULL,
+ "InsertVolume",
+ mount_path,
+ udi,
+ NULL);
+ } else {
+ tracker_db_interface_execute_procedure (iface, NULL,
+ "EnableVolume",
+ mount_path,
+ udi,
+ NULL);
+ }
+}
+
+void
+tracker_data_update_remove_volume (const gchar *udi)
+{
+ TrackerDBInterface *iface;
+
+ g_return_if_fail (udi != NULL);
+
+ iface = tracker_db_manager_get_db_interface (TRACKER_DB_COMMON);
+
+ tracker_db_interface_execute_procedure (iface, NULL,
+ "DisableVolume",
+ udi,
+ NULL);
+}
+
Modified: trunk/src/libtracker-data/tracker-data-update.h
==============================================================================
--- trunk/src/libtracker-data/tracker-data-update.h (original)
+++ trunk/src/libtracker-data/tracker-data-update.h Tue Nov 18 10:05:39 2008
@@ -80,6 +80,11 @@
/* XESAM API */
void tracker_data_update_delete_handled_events (TrackerDBInterface *iface);
+/* Volume handling */
+void tracker_data_update_add_volume (const gchar *udi,
+ const gchar *mount_path);
+void tracker_data_update_remove_volume (const gchar *udi);
+
G_END_DECLS
#endif /* __TRACKER_DATA_UPDATE_H__ */
Modified: trunk/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-indexer.c (original)
+++ trunk/src/tracker-indexer/tracker-indexer.c Tue Nov 18 10:05:39 2008
@@ -2614,6 +2614,12 @@
path,
enabled ? "yes" : "no");
+ if (enabled) {
+ tracker_data_update_add_volume (volume_uuid, path);
+ } else {
+ tracker_data_update_remove_volume (volume_uuid);
+ }
+
dbus_g_method_return (context);
tracker_dbus_request_success (request_id);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]