[tracker/direct-access: 23/47] libtracker-data: Do not do reindexing in read-only mode
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/direct-access: 23/47] libtracker-data: Do not do reindexing in read-only mode
- Date: Wed, 14 Jul 2010 16:46:10 +0000 (UTC)
commit b18cd2936b6138bb2ed7ee94754ac4cbee1b617f
Author: Jürg Billeter <j bitron ch>
Date: Thu Jul 8 10:33:45 2010 +0200
libtracker-data: Do not do reindexing in read-only mode
src/libtracker-data/tracker-db-manager.c | 48 ++++++++++++++++++++----------
1 files changed, 32 insertions(+), 16 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index 14277ff..fbdcbda 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -827,6 +827,11 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
* other things like the nfs lock file.
*/
if (flags & TRACKER_DB_MANAGER_FORCE_REINDEX || need_reindex) {
+ if (flags & TRACKER_DB_MANAGER_READONLY) {
+ /* no reindexing supported in read-only mode (direct access) */
+ return FALSE;
+ }
+
if (first_time) {
*first_time = TRUE;
}
@@ -843,7 +848,9 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
/* Load databases */
g_message ("Loading databases files...");
- } else {
+ } else if ((flags & TRACKER_DB_MANAGER_READONLY) == 0) {
+ /* do not do shutdown check for read-only mode (direct access) */
+
gboolean must_recreate;
/* Load databases */
@@ -927,14 +934,18 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
}
}
- in_use_file = g_open (in_use_filename,
- O_WRONLY | O_APPEND | O_CREAT | O_SYNC,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ if ((flags & TRACKER_DB_MANAGER_READONLY) == 0) {
+ /* do not create in-use file for read-only mode (direct access) */
- if (in_use_file >= 0) {
- fsync (in_use_file);
- close (in_use_file);
- }
+ in_use_file = g_open (in_use_filename,
+ O_WRONLY | O_APPEND | O_CREAT | O_SYNC,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+
+ if (in_use_file >= 0) {
+ fsync (in_use_file);
+ close (in_use_file);
+ }
+ }
g_free (in_use_filename);
@@ -969,7 +980,6 @@ void
tracker_db_manager_shutdown (void)
{
guint i;
- gchar *in_use_filename;
if (!initialized) {
return;
@@ -1026,15 +1036,21 @@ tracker_db_manager_shutdown (void)
initialized = FALSE;
locations_initialized = FALSE;
- in_use_filename = g_build_filename (g_get_user_data_dir (),
- "tracker",
- "data",
- IN_USE_FILENAME,
- NULL);
+ if ((tracker_db_manager_get_flags () & TRACKER_DB_MANAGER_READONLY) == 0) {
+ /* do not delete in-use file for read-only mode (direct access) */
- g_unlink (in_use_filename);
+ gchar *in_use_filename;
- g_free (in_use_filename);
+ in_use_filename = g_build_filename (g_get_user_data_dir (),
+ "tracker",
+ "data",
+ IN_USE_FILENAME,
+ NULL);
+
+ g_unlink (in_use_filename);
+
+ g_free (in_use_filename);
+ }
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]