Commit f9b87f0b authored by Philip Van Hoof's avatar Philip Van Hoof

Don't store last modseq, use max(tracker:modified) instead

Also changed the ontology to use xsd:integer instead of xsd:datetime.
This change requires running tracker-processes -r to restart the
ontology initialization.
parent b5bc4511
......@@ -89,5 +89,5 @@ tracker:transient a rdf:Property ;
tracker:modified a rdf:Property ;
nrl:maxCardinality 1 ;
rdfs:domain rdfs:Resource ;
rdfs:range xsd:dateTime .
rdfs:range xsd:integer .
......@@ -65,21 +65,6 @@
static gchar *ontologies_dir;
static gboolean initialized;
static void
tracker_data_store_modseq (void)
{
tracker_data_manager_set_db_option_int64 ("ModificationSequence",
tracker_data_get_modification_sequence ());
}
static void
tracker_data_restore_modseq (void)
{
tracker_data_set_modification_sequence (tracker_data_manager_get_db_option_int64 ("ModificationSequence"));
}
static void
load_ontology_file_from_path (const gchar *ontology_file)
{
......@@ -875,8 +860,6 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
create_decomposed_transient_metadata_tables (iface);
}
tracker_data_restore_modseq ();
initialized = TRUE;
return TRUE;
......@@ -888,7 +871,6 @@ tracker_data_manager_shutdown (void)
{
g_return_if_fail (initialized == TRUE);
tracker_data_store_modseq ();
tracker_db_manager_shutdown ();
initialized = FALSE;
......
......@@ -88,19 +88,6 @@ static TrackerStatementCallback delete_callback = NULL;
static gpointer delete_data;
static TrackerCommitCallback commit_callback = NULL;
static gpointer commit_data;
static gint64 modification_sequence;
gint64
tracker_data_get_modification_sequence (void)
{
return modification_sequence;
}
void
tracker_data_set_modification_sequence (gint64 modseq)
{
modification_sequence = modseq;
}
void
tracker_data_set_commit_statement_callback (TrackerCommitCallback callback,
......@@ -161,6 +148,39 @@ tracker_data_update_get_new_service_id (TrackerDBInterface *iface)
return ++max;
}
static guint32
tracker_data_update_get_next_modseq (void)
{
guint32 files_max;
TrackerDBResultSet *result_set;
TrackerDBInterface *temp_iface;
static guint32 max = 0;
if (G_LIKELY (max != 0)) {
return ++max;
}
temp_iface = tracker_db_manager_get_db_interface ();
result_set = tracker_db_interface_execute_query (temp_iface, NULL,
"SELECT MAX(\"tracker:modified\") AS A FROM \"rdfs:Resource\"");
if (result_set) {
GValue val = {0, };
_tracker_db_result_set_get_value (result_set, 0, &val);
if (G_VALUE_TYPE (&val) == G_TYPE_INT) {
files_max = g_value_get_int (&val);
max = MAX (files_max, max);
g_value_unset (&val);
}
g_object_unref (result_set);
}
return ++max;
}
static TrackerDataUpdateBufferTable *
cache_table_new (gboolean multiple_values)
{
......@@ -269,7 +289,7 @@ ensure_resource_id (const gchar *uri)
stmt = tracker_db_interface_create_statement (iface, "INSERT INTO \"rdfs:Resource\" (ID, Uri, \"tracker:modified\", Available) VALUES (?, ?, ?, 1)");
tracker_db_statement_bind_int (stmt, 0, id);
tracker_db_statement_bind_text (stmt, 1, uri);
tracker_db_statement_bind_int64 (stmt, 2, ++modification_sequence);
tracker_db_statement_bind_int (stmt, 2, tracker_data_update_get_next_modseq ());
tracker_db_statement_execute (stmt, NULL);
g_object_unref (stmt);
......@@ -1010,14 +1030,14 @@ tracker_data_insert_statement_common (const gchar *subject,
if (update_buffer.subject == NULL) {
GValue gvalue = { 0 };
g_value_init (&gvalue, G_TYPE_INT64);
g_value_init (&gvalue, G_TYPE_INT);
/* subject not yet in cache, retrieve or create ID */
update_buffer.subject = g_strdup (subject);
update_buffer.id = ensure_resource_id (update_buffer.subject);
update_buffer.types = tracker_data_query_rdf_type (update_buffer.id);
g_value_set_int64 (&gvalue, ++modification_sequence);
g_value_set_int (&gvalue, tracker_data_update_get_next_modseq ());
cache_insert_value ("rdfs:Resource", "tracker:modified", &gvalue, FALSE, FALSE);
}
......
......@@ -69,9 +69,6 @@ void tracker_data_commit_transaction (void);
void tracker_data_update_sparql (const gchar *update,
GError **error);
gint64 tracker_data_get_modification_sequence (void);
void tracker_data_set_modification_sequence (gint64 modseq);
/* Volume handling */
void tracker_data_update_enable_volume (const gchar *udi,
const gchar *mount_path);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment