summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libtracker-data/tracker-data-manager.c9
-rw-r--r--src/libtracker-data/tracker-db-interface-sqlite.c61
-rw-r--r--src/libtracker-data/tracker-db-interface-sqlite.h4
-rw-r--r--src/libtracker-data/tracker-db-manager.c149
-rw-r--r--src/libtracker-data/tracker-db-manager.h1
-rw-r--r--src/libtracker-direct/tracker-direct.c5
-rw-r--r--src/libtracker-sparql-backend/tracker-backend.vala2
-rw-r--r--src/libtracker-sparql/tracker-connection.c6
8 files changed, 153 insertions, 84 deletions
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index fe653b4a8..8898c92a6 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -3746,6 +3746,11 @@ write_ontologies_gvdb (TrackerDataManager *manager,
gchar *filename;
GFile *child;
+ if ((manager->flags & TRACKER_DB_MANAGER_IN_MEMORY) != 0)
+ return TRUE;
+ if (!manager->cache_location)
+ return TRUE;
+
child = g_file_get_child (manager->cache_location, "ontologies.gvdb");
filename = g_file_get_path (child);
g_object_unref (child);
@@ -3919,7 +3924,7 @@ tracker_data_manager_new (TrackerDBManagerFlags flags,
{
TrackerDataManager *manager;
- if (!cache_location) {
+ if ((flags & TRACKER_DB_MANAGER_IN_MEMORY) == 0 && !cache_location) {
g_warning ("Data storage location must be provided");
return NULL;
}
@@ -4143,7 +4148,7 @@ tracker_data_manager_initable_init (GInitable *initable,
return TRUE;
}
- if (!g_file_is_native (manager->cache_location)) {
+ if (manager->cache_location && !g_file_is_native (manager->cache_location)) {
g_set_error (error,
TRACKER_DATA_ONTOLOGY_ERROR,
TRACKER_DATA_UNSUPPORTED_LOCATION,
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c
index 61c3a1c11..074bf40f1 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -77,6 +77,7 @@ struct TrackerDBInterface {
GObject parent_instance;
gchar *filename;
+ gchar *shared_cache_key;
sqlite3 *db;
GHashTable *dynamic_statements;
@@ -157,7 +158,8 @@ static gboolean db_cursor_iter_next (TrackerDBCu
enum {
PROP_0,
PROP_FILENAME,
- PROP_FLAGS
+ PROP_FLAGS,
+ PROP_SHARED_CACHE_KEY,
};
enum {
@@ -1914,8 +1916,9 @@ open_database (TrackerDBInterface *db_interface,
{
int mode;
int result;
+ gchar *uri;
- g_assert (db_interface->filename != NULL);
+ g_assert (db_interface->filename != NULL || db_interface->shared_cache_key != NULL);
if ((db_interface->flags & TRACKER_DB_INTERFACE_READONLY) == 0) {
mode = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
@@ -1923,7 +1926,16 @@ open_database (TrackerDBInterface *db_interface,
mode = SQLITE_OPEN_READONLY;
}
- result = sqlite3_open_v2 (db_interface->filename, &db_interface->db, mode | SQLITE_OPEN_NOMUTEX, NULL);
+ if ((db_interface->flags & TRACKER_DB_INTERFACE_IN_MEMORY) != 0) {
+ mode |= SQLITE_OPEN_MEMORY | SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_URI;
+ uri = g_strdup_printf ("file:%s", db_interface->shared_cache_key);
+ } else {
+ uri = g_strdup (db_interface->filename);
+ }
+
+ result = sqlite3_open_v2 (uri, &db_interface->db, mode | SQLITE_OPEN_NOMUTEX, NULL);
+ g_free (uri);
+
if (result != SQLITE_OK) {
const gchar *str;
@@ -1931,10 +1943,13 @@ open_database (TrackerDBInterface *db_interface,
g_set_error (error,
TRACKER_DB_INTERFACE_ERROR,
TRACKER_DB_OPEN_ERROR,
- "Could not open sqlite3 database:'%s': %s", db_interface->filename, str);
+ "Could not open sqlite3 database:'%s': %s",
+ db_interface->filename ? db_interface->filename : "memory",
+ str);
return;
} else {
- g_debug ("Opened sqlite3 database:'%s'", db_interface->filename);
+ g_debug ("Opened sqlite3 database:'%s'",
+ db_interface->filename? db_interface->filename : "memory");
}
/* Set our unicode collation function */
@@ -1999,6 +2014,9 @@ tracker_db_interface_sqlite_set_property (GObject *object,
case PROP_FILENAME:
db_iface->filename = g_value_dup_string (value);
break;
+ case PROP_SHARED_CACHE_KEY:
+ db_iface->shared_cache_key = g_value_dup_string (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -2021,6 +2039,9 @@ tracker_db_interface_sqlite_get_property (GObject *object,
case PROP_FILENAME:
g_value_set_string (value, db_iface->filename);
break;
+ case PROP_SHARED_CACHE_KEY:
+ g_value_set_string (value, db_iface->shared_cache_key);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -2419,6 +2440,7 @@ tracker_db_interface_sqlite_finalize (GObject *object)
g_debug ("Closed sqlite3 database:'%s'", db_interface->filename);
g_free (db_interface->filename);
+ g_free (db_interface->shared_cache_key);
if (db_interface->user_data && db_interface->user_data_destroy_notify)
db_interface->user_data_destroy_notify (db_interface->user_data);
@@ -2450,6 +2472,14 @@ tracker_db_interface_class_init (TrackerDBInterfaceClass *class)
"Interface flags",
TRACKER_TYPE_DB_INTERFACE_FLAGS, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_SHARED_CACHE_KEY,
+ g_param_spec_string ("shared-cache-key",
+ "Shared cache key",
+ "Shared cache key",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
static void
@@ -2822,6 +2852,7 @@ tracker_db_interface_execute_vquery (TrackerDBInterface *db_interface,
TrackerDBInterface *
tracker_db_interface_sqlite_new (const gchar *filename,
+ const gchar *shared_cache_key,
TrackerDBInterfaceFlags flags,
GError **error)
{
@@ -2833,6 +2864,7 @@ tracker_db_interface_sqlite_new (const gchar *filename,
&internal_error,
"filename", filename,
"flags", flags,
+ "shared-cache-key", shared_cache_key,
NULL);
if (internal_error) {
@@ -3545,13 +3577,24 @@ tracker_db_interface_attach_database (TrackerDBInterface *db_interface,
const gchar *name,
GError **error)
{
- gchar *sql, *path;
+ gchar *sql, *uri = NULL;
sqlite3_stmt *stmt;
gboolean retval;
- path = g_file_get_path (file);
- sql = g_strdup_printf ("ATTACH DATABASE \"%s\" AS \"%s\"", path, name);
- g_free (path);
+ g_return_val_if_fail (file || db_interface->shared_cache_key, FALSE);
+
+ if (file) {
+ uri = g_file_get_path (file);
+ } else if (db_interface->shared_cache_key &&
+ (db_interface->flags & TRACKER_DB_INTERFACE_IN_MEMORY) != 0) {
+ uri = g_strdup_printf ("file:%s-%s?mode=memory&cache=shared",
+ db_interface->shared_cache_key,
+ name);
+ }
+
+ sql = g_strdup_printf ("ATTACH DATABASE \"%s\" AS \"%s\"",
+ uri, name);
+ g_free (uri);
stmt = tracker_db_interface_prepare_stmt (db_interface, sql, error);
g_free (sql);
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.h b/src/libtracker-data/tracker-db-interface-sqlite.h
index f8dc3c07b..9655f1999 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.h
+++ b/src/libtracker-data/tracker-db-interface-sqlite.h
@@ -39,10 +39,12 @@ typedef void (*TrackerDBWalCallback) (TrackerDBInterface *iface,
typedef enum {
TRACKER_DB_INTERFACE_READONLY = 1 << 0,
- TRACKER_DB_INTERFACE_USE_MUTEX = 1 << 1
+ TRACKER_DB_INTERFACE_USE_MUTEX = 1 << 1,
+ TRACKER_DB_INTERFACE_IN_MEMORY = 1 << 2,
} TrackerDBInterfaceFlags;
TrackerDBInterface *tracker_db_interface_sqlite_new (const gchar *filename,
+ const gchar *shared_cache_key,
TrackerDBInterfaceFlags flags,
GError **error);
gint64 tracker_db_interface_sqlite_get_last_insert_id (TrackerDBInterface *interface);
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index 56410448f..46bdea4a9 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -44,6 +44,7 @@
#include "tracker-db-interface-sqlite.h"
#include "tracker-db-interface.h"
#include "tracker-data-manager.h"
+#include "tracker-uuid.h"
#define UNKNOWN_STATUS 0.5
@@ -131,6 +132,7 @@ struct _TrackerDBManager {
gchar *user_data_dir;
gchar *in_use_filename;
GFile *cache_location;
+ gchar *shared_cache_key;
TrackerDBManagerFlags flags;
guint s_cache_size;
guint u_cache_size;
@@ -192,6 +194,7 @@ db_set_params (TrackerDBInterface *iface,
const gchar *database,
gint cache_size,
gint page_size,
+ gboolean enable_wal,
GError **error)
{
GError *internal_error = NULL;
@@ -200,31 +203,31 @@ db_set_params (TrackerDBInterface *iface,
tracker_db_interface_execute_query (iface, NULL, "PRAGMA \"%s\".synchronous = NORMAL", database);
tracker_db_interface_execute_query (iface, NULL, "PRAGMA \"%s\".auto_vacuum = 0", database);
- stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_NONE,
- &internal_error,
- "PRAGMA \"%s\".journal_mode = WAL", database);
+ if (enable_wal) {
+ stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_NONE,
+ &internal_error,
+ "PRAGMA \"%s\".journal_mode = WAL", database);
- if (internal_error) {
- g_info ("Can't set journal mode to WAL: '%s'",
- internal_error->message);
- g_propagate_error (error, internal_error);
- } else {
- TrackerDBCursor *cursor;
-
- cursor = tracker_db_statement_start_cursor (stmt, NULL);
- if (tracker_db_cursor_iter_next (cursor, NULL, NULL)) {
- if (g_ascii_strcasecmp (tracker_db_cursor_get_string (cursor, 0, NULL), "WAL") != 0) {
- g_set_error (error,
- TRACKER_DB_INTERFACE_ERROR,
- TRACKER_DB_OPEN_ERROR,
- "Can't set journal mode to WAL");
+ if (internal_error) {
+ g_info ("Can't set journal mode to WAL: '%s'",
+ internal_error->message);
+ g_propagate_error (error, internal_error);
+ } else {
+ TrackerDBCursor *cursor;
+
+ cursor = tracker_db_statement_start_cursor (stmt, NULL);
+ if (tracker_db_cursor_iter_next (cursor, NULL, NULL)) {
+ if (g_ascii_strcasecmp (tracker_db_cursor_get_string (cursor, 0, NULL), "WAL") != 0) {
+ g_set_error (error,
+ TRACKER_DB_INTERFACE_ERROR,
+ TRACKER_DB_OPEN_ERROR,
+ "Can't set journal mode to WAL");
+ }
}
+ g_object_unref (cursor);
}
- g_object_unref (cursor);
- }
- if (stmt) {
- g_object_unref (stmt);
+ g_clear_object (&stmt);
}
/* disable autocheckpoint */
@@ -246,6 +249,9 @@ tracker_db_manager_remove_all (TrackerDBManager *db_manager)
{
gchar *filename;
+ if ((db_manager->flags & TRACKER_DB_MANAGER_IN_MEMORY) != 0)
+ return;
+
g_info ("Removing all files for database %s", db_manager->db.abs_filename);
g_unlink (db_manager->db.abs_filename);
@@ -477,6 +483,10 @@ tracker_db_manager_ensure_location (TrackerDBManager *db_manager,
{
gchar *dir;
+ if ((db_manager->flags & TRACKER_DB_MANAGER_IN_MEMORY) != 0) {
+ return;
+ }
+
if (db_manager->locations_initialized) {
return;
}
@@ -505,7 +515,8 @@ perform_recreate (TrackerDBManager *db_manager,
g_clear_object (&db_manager->db.iface);
g_clear_object (&db_manager->db.wal_iface);
- if (!tracker_file_system_has_enough_space (db_manager->data_dir, TRACKER_DB_MIN_REQUIRED_SPACE, TRUE)) {
+ if ((db_manager->flags & TRACKER_DB_MANAGER_IN_MEMORY) == 0 &&
+ !tracker_file_system_has_enough_space (db_manager->data_dir, TRACKER_DB_MIN_REQUIRED_SPACE, TRUE)) {
g_set_error (error,
TRACKER_DB_INTERFACE_ERROR,
TRACKER_DB_OPEN_ERROR,
@@ -539,18 +550,9 @@ tracker_db_manager_new (TrackerDBManagerFlags flags,
TrackerDBVersion version;
gboolean need_reindex;
int in_use_file;
- gboolean loaded = FALSE;
TrackerDBInterface *resources_iface;
GError *internal_error = NULL;
- if (!cache_location) {
- g_set_error (error,
- TRACKER_DATA_ONTOLOGY_ERROR,
- TRACKER_DATA_UNSUPPORTED_LOCATION,
- "All data storage and ontology locations must be provided");
- return NULL;
- }
-
db_manager = g_object_new (TRACKER_TYPE_DB_MANAGER, NULL);
db_manager->vtab_data = vtab_data;
@@ -572,18 +574,22 @@ tracker_db_manager_new (TrackerDBManagerFlags flags,
g_set_object (&db_manager->cache_location, cache_location);
g_weak_ref_init (&db_manager->iface_data, iface_data);
- tracker_db_manager_ensure_location (db_manager, cache_location);
- db_manager->in_use_filename = g_build_filename (db_manager->data_dir,
- IN_USE_FILENAME,
- NULL);
+ if ((db_manager->flags & TRACKER_DB_MANAGER_IN_MEMORY) == 0) {
+ tracker_db_manager_ensure_location (db_manager, cache_location);
+ db_manager->in_use_filename = g_build_filename (db_manager->data_dir,
+ IN_USE_FILENAME,
+ NULL);
- /* Don't do need_reindex checks for readonly (direct-access) */
- if ((flags & TRACKER_DB_MANAGER_READONLY) == 0) {
+ /* Don't do need_reindex checks for readonly (direct-access) */
+ if ((flags & TRACKER_DB_MANAGER_READONLY) == 0) {
- /* Make sure the directories exist */
- g_debug ("Checking database directories exist");
+ /* Make sure the directories exist */
+ g_debug ("Checking database directories exist");
- g_mkdir_with_parents (db_manager->data_dir, 00755);
+ g_mkdir_with_parents (db_manager->data_dir, 00755);
+ }
+ } else {
+ db_manager->shared_cache_key = tracker_generate_uuid (NULL);
}
g_debug ("Checking whether database files exist");
@@ -594,7 +600,9 @@ tracker_db_manager_new (TrackerDBManagerFlags flags,
* There's no need to check for files not existing (for
* reindex) if reindexing is already needed.
*/
- if (!g_file_test (db_manager->db.abs_filename, G_FILE_TEST_EXISTS)) {
+ if ((db_manager->flags & TRACKER_DB_MANAGER_IN_MEMORY) != 0) {
+ need_reindex = TRUE;
+ } else if (!g_file_test (db_manager->db.abs_filename, G_FILE_TEST_EXISTS)) {
if ((flags & TRACKER_DB_MANAGER_READONLY) == 0) {
g_info ("Could not find database file:'%s', reindex will be forced", db_manager->db.abs_filename);
need_reindex = TRUE;
@@ -678,10 +686,6 @@ tracker_db_manager_new (TrackerDBManagerFlags flags,
}
tracker_db_manager_update_version (db_manager);
-
- /* Load databases */
- g_info ("Loading files for database %s...", db_manager->db.abs_filename);
-
} else if ((flags & TRACKER_DB_MANAGER_READONLY) == 0) {
/* do not do shutdown check for read-only mode (direct access) */
gboolean must_recreate = FALSE;
@@ -736,8 +740,6 @@ tracker_db_manager_new (TrackerDBManagerFlags flags,
if (!must_recreate) {
gchar *busy_status;
- loaded = TRUE;
-
/* Report OPERATION - STATUS */
busy_status = g_strdup_printf ("%s - %s",
busy_operation,
@@ -805,7 +807,6 @@ tracker_db_manager_new (TrackerDBManagerFlags flags,
g_propagate_error (error, internal_error);
return FALSE;
}
- loaded = FALSE;
} else {
if (internal_error) {
g_propagate_error (error, internal_error);
@@ -814,7 +815,7 @@ tracker_db_manager_new (TrackerDBManagerFlags flags,
}
}
- if ((flags & TRACKER_DB_MANAGER_READONLY) == 0) {
+ if ((flags & (TRACKER_DB_MANAGER_READONLY | TRACKER_DB_MANAGER_IN_MEMORY)) == 0) {
/* do not create in-use file for read-only mode (direct access) */
in_use_file = g_open (db_manager->in_use_filename,
O_WRONLY | O_APPEND | O_CREAT | O_SYNC,
@@ -880,12 +881,13 @@ tracker_db_manager_finalize (GObject *object)
g_free (db_manager->data_dir);
- if (!readonly) {
+ if (db_manager->in_use_filename && !readonly) {
/* do not delete in-use file for read-only mode (direct access) */
g_unlink (db_manager->in_use_filename);
}
g_free (db_manager->in_use_filename);
+ g_free (db_manager->shared_cache_key);
G_OBJECT_CLASS (tracker_db_manager_parent_class)->finalize (object);
}
@@ -903,8 +905,11 @@ tracker_db_manager_create_db_interface (TrackerDBManager *db_manager,
flags |= TRACKER_DB_INTERFACE_READONLY;
if (db_manager->flags & TRACKER_DB_MANAGER_ENABLE_MUTEXES)
flags |= TRACKER_DB_INTERFACE_USE_MUTEX;
+ if (db_manager->flags & TRACKER_DB_MANAGER_IN_MEMORY)
+ flags |= TRACKER_DB_INTERFACE_IN_MEMORY;
connection = tracker_db_interface_sqlite_new (db_manager->db.abs_filename,
+ db_manager->shared_cache_key,
flags,
&internal_error);
if (internal_error) {
@@ -924,6 +929,7 @@ tracker_db_manager_create_db_interface (TrackerDBManager *db_manager,
db_set_params (connection, "main",
db_manager->db.cache_size,
db_manager->db.page_size,
+ !(db_manager->flags & TRACKER_DB_MANAGER_IN_MEMORY),
&internal_error);
if (internal_error) {
@@ -1136,6 +1142,8 @@ tracker_db_manager_get_writable_db_interface (TrackerDBManager *db_manager)
gboolean
tracker_db_manager_has_enough_space (TrackerDBManager *db_manager)
{
+ if ((db_manager->flags & TRACKER_DB_MANAGER_IN_MEMORY) != 0)
+ return TRUE;
return tracker_file_system_has_enough_space (db_manager->data_dir, TRACKER_DB_MIN_REQUIRED_SPACE, FALSE);
}
@@ -1189,6 +1197,8 @@ tracker_db_manager_check_perform_vacuum (TrackerDBManager *db_manager)
{
TrackerDBInterface *iface;
+ if ((db_manager->flags & TRACKER_DB_MANAGER_IN_MEMORY) != 0)
+ return;
if (tracker_file_get_size (db_manager->db.abs_filename) < TRACKER_VACUUM_CHECK_SIZE)
return;
@@ -1204,23 +1214,25 @@ tracker_db_manager_attach_database (TrackerDBManager *db_manager,
GError **error)
{
gchar *filename, *escaped;
- GFile *file;
-
- filename = g_strdup_printf ("%s.db", name);
- escaped = g_uri_escape_string (filename, NULL, FALSE);
- file = g_file_get_child (db_manager->cache_location, escaped);
- g_free (filename);
- g_free (escaped);
-
- if (create) {
- GError *inner_error = NULL;
-
- /* Create the database from scratch */
- if (!g_file_delete (file, NULL, &inner_error)) {
- if (!g_error_matches (inner_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
- g_object_unref (file);
- g_propagate_error (error, inner_error);
- return FALSE;
+ GFile *file = NULL;
+
+ if (db_manager->cache_location) {
+ filename = g_strdup_printf ("%s.db", name);
+ escaped = g_uri_escape_string (filename, NULL, FALSE);
+ file = g_file_get_child (db_manager->cache_location, escaped);
+ g_free (filename);
+ g_free (escaped);
+
+ if (create) {
+ GError *inner_error = NULL;
+
+ /* Create the database from scratch */
+ if (!g_file_delete (file, NULL, &inner_error)) {
+ if (!g_error_matches (inner_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
+ g_object_unref (file);
+ g_propagate_error (error, inner_error);
+ return FALSE;
+ }
}
}
}
@@ -1230,10 +1242,11 @@ tracker_db_manager_attach_database (TrackerDBManager *db_manager,
return FALSE;
}
- g_object_unref (file);
+ g_clear_object (&file);
db_set_params (iface, name,
db_manager->db.cache_size,
db_manager->db.page_size,
+ !(db_manager->flags & TRACKER_DB_MANAGER_IN_MEMORY),
error);
return TRUE;
}
diff --git a/src/libtracker-data/tracker-db-manager.h b/src/libtracker-data/tracker-db-manager.h
index 96988e239..91136dc3a 100644
--- a/src/libtracker-data/tracker-db-manager.h
+++ b/src/libtracker-data/tracker-db-manager.h
@@ -47,6 +47,7 @@ typedef enum {
TRACKER_DB_MANAGER_FTS_ENABLE_UNACCENT = 1 << 7,
TRACKER_DB_MANAGER_FTS_ENABLE_STOP_WORDS = 1 << 8,
TRACKER_DB_MANAGER_FTS_IGNORE_NUMBERS = 1 << 9,
+ TRACKER_DB_MANAGER_IN_MEMORY = 1 << 10,
} TrackerDBManagerFlags;
typedef struct _TrackerDBManager TrackerDBManager;
diff --git a/src/libtracker-direct/tracker-direct.c b/src/libtracker-direct/tracker-direct.c
index 862dbffec..c625cee10 100644
--- a/src/libtracker-direct/tracker-direct.c
+++ b/src/libtracker-direct/tracker-direct.c
@@ -257,6 +257,9 @@ tracker_direct_connection_initable_init (GInitable *initable,
db_flags = translate_flags (priv->flags);
+ if (!priv->store)
+ db_flags |= TRACKER_DB_MANAGER_IN_MEMORY;
+
/* Init data manager */
if (!priv->ontology &&
(db_flags & TRACKER_DB_MANAGER_READONLY) == 0) {
@@ -1035,7 +1038,7 @@ tracker_direct_connection_new (TrackerSparqlConnectionFlags flags,
GFile *ontology,
GError **error)
{
- g_return_val_if_fail (G_IS_FILE (store), NULL);
+ g_return_val_if_fail (!store || G_IS_FILE (store), NULL);
g_return_val_if_fail (!ontology || G_IS_FILE (ontology), NULL);
g_return_val_if_fail (!error || !*error, NULL);
diff --git a/src/libtracker-sparql-backend/tracker-backend.vala b/src/libtracker-sparql-backend/tracker-backend.vala
index 34e95bd6a..7e8ee79fb 100644
--- a/src/libtracker-sparql-backend/tracker-backend.vala
+++ b/src/libtracker-sparql-backend/tracker-backend.vala
@@ -38,7 +38,7 @@ public static Tracker.Sparql.Connection tracker_sparql_connection_bus_new (strin
return new Tracker.Bus.Connection (service, path, dbus_conn);
}
-public static Tracker.Sparql.Connection tracker_sparql_connection_new (Tracker.Sparql.ConnectionFlags flags, File store, File? ontology, Cancellable? cancellable = null) throws GLib.Error, Tracker.Sparql.Error, IOError {
+public static Tracker.Sparql.Connection tracker_sparql_connection_new (Tracker.Sparql.ConnectionFlags flags, File? store, File? ontology, Cancellable? cancellable = null) throws GLib.Error, Tracker.Sparql.Error, IOError {
var conn = new Tracker.Direct.Connection (flags, store, ontology);
conn.init (cancellable);
return conn;
diff --git a/src/libtracker-sparql/tracker-connection.c b/src/libtracker-sparql/tracker-connection.c
index c5be4831e..16c72d723 100644
--- a/src/libtracker-sparql/tracker-connection.c
+++ b/src/libtracker-sparql/tracker-connection.c
@@ -53,7 +53,7 @@ tracker_sparql_connection_class_init (TrackerSparqlConnectionClass *klass)
/**
* tracker_sparql_connection_new:
* @flags: values from #TrackerSparqlConnectionFlags
- * @store: the directory that contains the database, as a #GFile
+ * @store: the directory that contains the database as a #GFile, or %NULL
* @ontology: (nullable): the directory that contains the database schemas as
* a #GFile, or %NULL to use the default schemas.
* @cancellable: (nullable): a #GCancellable, or %NULL
@@ -64,6 +64,8 @@ tracker_sparql_connection_class_init (TrackerSparqlConnectionClass *klass)
* To connect to databases managed by other processes, use
* tracker_sparql_connection_bus_new().
*
+ * If @store is %NULL, the database will be created in memory.
+ *
* Returns: (transfer full): a new #TrackerSparqlConnection. Call
* g_object_unref() on the object when no longer used.
*
@@ -73,7 +75,7 @@ tracker_sparql_connection_class_init (TrackerSparqlConnectionClass *klass)
/**
* tracker_sparql_connection_new_async:
* @flags: values from #TrackerSparqlConnectionFlags
- * @store: the directory that contains the database, as a #GFile
+ * @store: the directory that contains the database as a #GFile, or %NULL
* @ontology: (nullable): the directory that contains the database schemas as
* a #GFile, or %NULL to use the default schemas.
* @cancellable: (nullable): a #GCancellable, or %NULL