[tracker/binary-log-2: 1/47] Removed old backup code
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/binary-log-2: 1/47] Removed old backup code
- Date: Mon, 11 Jan 2010 16:34:20 +0000 (UTC)
commit b50bd83dbe0f2aac766ee69404c4f9286e159391
Author: Philip Van Hoof <philip codeminded be>
Date: Mon Dec 28 10:34:52 2009 +0100
Removed old backup code
- Removed periodic backup code
- Stubbed DBus API backup code
src/libtracker-data/tracker-data-backup.c | 216 +------------------
src/libtracker-db/Makefile.am | 2 -
src/libtracker-db/tracker-db-backup.c | 339 -----------------------------
src/libtracker-db/tracker-db-backup.h | 54 -----
src/libtracker-db/tracker-db-manager.c | 75 -------
src/libtracker-db/tracker-db.h | 1 -
src/tracker-store/tracker-store.c | 41 ----
7 files changed, 7 insertions(+), 721 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-backup.c b/src/libtracker-data/tracker-data-backup.c
index 0acd8c8..ee1c4fe 100644
--- a/src/libtracker-data/tracker-data-backup.c
+++ b/src/libtracker-data/tracker-data-backup.c
@@ -24,125 +24,13 @@
#include <libtracker-db/tracker-db-manager.h>
#include <libtracker-db/tracker-db-journal.h>
-#include <libtracker-db/tracker-db-backup.h>
#include "tracker-data-backup.h"
-typedef struct {
- GFile *destination, *journal, *file;
- TrackerDataBackupFinished callback;
- gpointer user_data;
- GDestroyNotify destroy;
- GError *error;
-} BackupSaveInfo;
-
-static void
-free_backup_save_info (BackupSaveInfo *info)
+GQuark
+tracker_data_backup_error_quark (void)
{
- if (info->destination) {
- g_object_unref (info->destination);
- }
- if (info->journal) {
- g_object_unref (info->journal);
- }
- if (info->file) {
- g_object_unref (info->file);
- }
-
- if (info->destroy) {
- info->destroy (info->user_data);
- }
-
- g_clear_error (&info->error);
-
- g_free (info);
-}
-
-
-static void
-on_meta_copied (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- BackupSaveInfo *info = user_data;
- GError *error = NULL;
-
- g_file_copy_finish (info->file, res, &error);
-
- if (info->callback) {
- info->callback (error, info->user_data);
- }
-
- free_backup_save_info (info);
-
- g_clear_error (&error);
-}
-
-static void
-on_journal_copied (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- BackupSaveInfo *info = user_data;
- GError *error = NULL;
-
- if (!g_file_copy_finish (info->journal, res, &error)) {
- if (info->callback) {
- info->callback (error, info->user_data);
- }
- free_backup_save_info (info);
- } else {
- g_file_copy_async (info->file, info->destination,
- G_FILE_COPY_OVERWRITE,
- G_PRIORITY_HIGH,
- NULL, NULL, NULL,
- on_meta_copied,
- info);
- }
-
- g_clear_error (&error);
-}
-
-static void
-save_copy_procedure (BackupSaveInfo *info)
-{
- GFile *journal_o;
-
- journal_o = g_file_new_for_path (tracker_db_journal_filename ());
-
- if (g_file_query_exists (journal_o, NULL)) {
- g_file_copy_async (journal_o, info->journal,
- G_FILE_COPY_OVERWRITE,
- G_PRIORITY_HIGH,
- NULL, NULL, NULL,
- on_journal_copied,
- info);
- } else {
- g_file_copy_async (info->file, info->destination,
- G_FILE_COPY_OVERWRITE,
- G_PRIORITY_HIGH,
- NULL, NULL, NULL,
- on_meta_copied,
- info);
- }
-
- g_object_unref (journal_o);
-}
-
-static void
-on_backup_finished (GError *error, gpointer user_data)
-{
- BackupSaveInfo *info = user_data;
-
- if (error) {
- if (info->callback) {
- info->callback (error, info->user_data);
- }
- free_backup_save_info (info);
- return;
- }
-
- save_copy_procedure (info);
+ return g_quark_from_static_string ("tracker-data-backup-error-quark");
}
void
@@ -152,76 +40,8 @@ tracker_data_backup_save (GFile *destination,
gpointer user_data,
GDestroyNotify destroy)
{
- BackupSaveInfo *info;
-
- info = g_new0 (BackupSaveInfo, 1);
- info->destination = g_object_ref (destination);
- info->journal = g_object_ref (journal);
- info->callback = callback;
- info->user_data = user_data;
- info->destroy = destroy;
-
- info->file = tracker_db_backup_file (NULL, TRACKER_DB_BACKUP_META_FILENAME);
-
- if (g_file_query_exists (info->file, NULL)) {
- /* Making a backup just means copying meta-backup.db */
- save_copy_procedure (info);
- } else {
- /* If we don't have a meta-backup.db yet, we first make one */
- tracker_db_backup_save (on_backup_finished,
- info, NULL);
- }
-}
-
-static gboolean
-on_restore_done (gpointer user_data)
-{
- BackupSaveInfo *info = user_data;
-
- if (info->callback) {
- info->callback (info->error, info->user_data);
- }
-
- free_backup_save_info (info);
-
- return FALSE;
-}
-
-static void
-restore_copy_procedure (BackupSaveInfo *info)
-{
- GFile *journal_d;
- GError *error = NULL;
-
- /* Restore should block the mainloop until finished */
-
- journal_d = g_file_new_for_path (tracker_db_journal_filename ());
-
- if (g_file_query_exists (journal_d, NULL)) {
- g_file_copy (info->journal, journal_d,
- G_FILE_COPY_OVERWRITE,
- NULL, NULL, NULL,
- &error);
- }
-
- g_object_unref (journal_d);
-
- if (error) {
- goto error_handle;
- }
-
- g_file_copy (info->destination, info->file,
- G_FILE_COPY_OVERWRITE,
- NULL, NULL, NULL,
- &error);
-
- if (error) {
- goto error_handle;
- }
-
- error_handle:
-
- info->error = error;
+ // TODO: Unimplemented
+ g_critical ("tracker_data_backup_save unimplemented");
}
void
@@ -231,29 +51,7 @@ tracker_data_backup_restore (GFile *backup,
gpointer user_data,
GDestroyNotify destroy)
{
- BackupSaveInfo *info;
-
- tracker_db_manager_disconnect ();
- tracker_db_journal_close ();
-
- info = g_new0 (BackupSaveInfo, 1);
- info->destination = g_object_ref (backup);
- info->journal = g_object_ref (journal);
- info->callback = callback;
- info->user_data = user_data;
- info->destroy = destroy;
-
- info->file = tracker_db_backup_file (NULL, TRACKER_DB_BACKUP_META_FILENAME);
-
- /* This is all synchronous, blocking the mainloop indeed */
-
- restore_copy_procedure (info);
-
- tracker_db_journal_open ();
- tracker_db_manager_reconnect ();
-
- tracker_db_backup_sync_fts ();
-
- g_idle_add (on_restore_done, info);
+ // TODO: Unimplemented
+ g_critical ("tracker_data_backup_restore");
}
diff --git a/src/libtracker-db/Makefile.am b/src/libtracker-db/Makefile.am
index c8399ad..dc99f0e 100644
--- a/src/libtracker-db/Makefile.am
+++ b/src/libtracker-db/Makefile.am
@@ -19,7 +19,6 @@ libtracker_db_la_SOURCES = \
tracker-db-interface.c \
tracker-db-interface-sqlite.c \
tracker-db-manager.c \
- tracker-db-backup.c \
tracker-db-journal.c
noinst_HEADERS = \
@@ -28,7 +27,6 @@ noinst_HEADERS = \
tracker-db-interface.h \
tracker-db-interface-sqlite.h \
tracker-db-manager.h \
- tracker-db-backup.h \
tracker-db-journal.h
libtracker_db_la_LIBADD = \
diff --git a/src/libtracker-db/tracker-db-manager.c b/src/libtracker-db/tracker-db-manager.c
index 63d1f45..a5eccea 100644
--- a/src/libtracker-db/tracker-db-manager.c
+++ b/src/libtracker-db/tracker-db-manager.c
@@ -35,7 +35,6 @@
#include <libtracker-common/tracker-utils.h>
#include "tracker-db-journal.h"
-#include "tracker-db-backup.h"
#include "tracker-db-manager.h"
#include "tracker-db-interface-sqlite.h"
#include "tracker-db-interface.h"
@@ -864,16 +863,8 @@ db_manager_remove_all (gboolean rm_backup_and_log, gboolean not_meta)
if (rm_backup_and_log) {
GFile *file;
- gchar *path;
const gchar *cpath;
- file = tracker_db_backup_file (NULL, TRACKER_DB_BACKUP_META_FILENAME);
- path = g_file_get_path (file);
- g_message (" Removing database:'%s'",
- path);
- g_free (path);
- g_file_delete (file, NULL, NULL);
- g_object_unref (file);
cpath = tracker_db_journal_filename ();
g_message (" Removing database:'%s'",
cpath);
@@ -1019,65 +1010,6 @@ tracker_db_manager_ensure_locale (void)
g_free (stored_locale);
}
-static gboolean
-check_meta_backup (gboolean *did_copy)
-{
- const gchar *meta_filename;
- gboolean retval = FALSE;
-
- /* This is currently the only test for need_journal. We should add a
- * couple tests that test meta.db against consistenty, and if not
- * good, copy meta-backup.db over and set need_journal (being less
- * conservative about using the backup, and not trusting the meta.db
- * as much as we do right now) */
-
- meta_filename = dbs[TRACKER_DB_METADATA].abs_filename;
-
- if (meta_filename) {
- GFile *file;
-
- file = g_file_new_for_path (meta_filename);
-
- /* (more) Checks for a healthy meta.db should happen here */
-
- if (!g_file_query_exists (file, NULL)) {
- GFile *backup;
-
- backup = tracker_db_backup_file (NULL, TRACKER_DB_BACKUP_META_FILENAME);
-
- if (g_file_query_exists (backup, NULL)) {
- GError *error = NULL;
-
- /* Note that we leave meta-backup.db as is, it'll
- * be overwritten first-next time tracker-store.c's
- * sync_idle_handler will instruct this. */
-
- g_file_copy (backup, file, G_FILE_COPY_OVERWRITE,
- NULL, NULL, NULL, &error);
-
- if (!error && did_copy) {
- *did_copy = TRUE;
- }
-
- g_clear_error (&error);
- }
-
- /* We always play the journal in case meta.db wasn't
- * healthy. Also if meta-backup.db didn't exist: that
- * just means that tracker-store.c's sync_idle_handler
- * didn't yet ran (meanwhile a first log-file is yet
- * already being made) */
-
- retval = TRUE;
-
- g_object_unref (backup);
- }
-
- g_object_unref (file);
- }
-
- return retval;
-}
gboolean
tracker_db_manager_init (TrackerDBManagerFlags flags,
@@ -1195,13 +1127,6 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
}
}
- if (need_journal) {
- /* That did_copy is used for called db_manager_remove_all, we
- * don't want it to also remove our freshly copied meta.db file. */
-
- *need_journal = check_meta_backup (&did_copy);
- }
-
/* If we are just initializing to remove the databases,
* return here.
*/
diff --git a/src/libtracker-db/tracker-db.h b/src/libtracker-db/tracker-db.h
index a3c5b87..9e5d809 100644
--- a/src/libtracker-db/tracker-db.h
+++ b/src/libtracker-db/tracker-db.h
@@ -28,7 +28,6 @@ G_BEGIN_DECLS
#define __LIBTRACKER_DB_INSIDE__
-#include "tracker-db-backup.h"
#include "tracker-db-dbus.h"
#include "tracker-db-interface.h"
#include "tracker-db-interface-sqlite.h"
diff --git a/src/tracker-store/tracker-store.c b/src/tracker-store/tracker-store.c
index 4ea4de8..6d47de0 100644
--- a/src/tracker-store/tracker-store.c
+++ b/src/tracker-store/tracker-store.c
@@ -26,7 +26,6 @@
#include <libtracker-common/tracker-dbus.h>
#include <libtracker-db/tracker-db-dbus.h>
-#include <libtracker-db/tracker-db-backup.h>
#include <libtracker-db/tracker-db-journal.h>
#include <libtracker-db/tracker-db-interface-sqlite.h>
#include <libtracker-db/tracker-db-journal.h>
@@ -38,7 +37,6 @@
#include "tracker-store.h"
#define TRACKER_STORE_TRANSACTION_MAX 4000 /* At commit is journal fsynced too */
-#define TRACKER_STORE_JOURNAL_TIMEOUT_BEFORE_BACKUP (60 * 60 * 2) /* Two hours before backup */
typedef struct {
gboolean have_handler, have_sync_handler;
@@ -170,21 +168,9 @@ end_batch (TrackerStorePrivate *private)
}
static void
-on_backup_done (GError *error, gpointer user_data)
-{
- if (!error) {
- tracker_db_journal_truncate ();
- }
-}
-
-static void
log_to_journal (TrackerStorePrivate *private, const gchar *query)
{
tracker_db_journal_log (query);
-
- if (tracker_db_journal_get_size () > TRACKER_DB_JOURNAL_MAX_SIZE) {
- tracker_db_backup_save (on_backup_done, NULL, NULL);
- }
}
static gboolean
@@ -288,14 +274,6 @@ queue_idle_handler (gpointer user_data)
return !g_queue_is_empty (private->queue);
}
-static gboolean
-sync_idle_handler (gpointer user_data)
-{
- tracker_db_backup_save (on_backup_done, NULL, NULL);
-
- return TRUE;
-}
-
static void
queue_idle_destroy (gpointer user_data)
{
@@ -304,17 +282,6 @@ queue_idle_destroy (gpointer user_data)
private->have_handler = FALSE;
}
-
-static void
-sync_idle_destroy (gpointer user_data)
-{
- TrackerStorePrivate *private = user_data;
-
- tracker_db_journal_close ();
-
- private->have_sync_handler = FALSE;
-}
-
void
tracker_store_flush_journal (void)
{
@@ -379,14 +346,6 @@ tracker_store_init (gboolean load_journal)
}
tracker_db_journal_open ();
-
- private->start_log = TRUE;
-
- private->sync_handler = g_timeout_add_seconds_full (G_PRIORITY_LOW,
- TRACKER_STORE_JOURNAL_TIMEOUT_BEFORE_BACKUP,
- sync_idle_handler,
- private,
- sync_idle_destroy);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]