[tracker/tracker-0.10] libtracker-data, tracker-store: Improve error reporting for backup
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-0.10] libtracker-data, tracker-store: Improve error reporting for backup
- Date: Thu, 5 May 2011 12:58:10 +0000 (UTC)
commit d01d8fc810b1f4838acda514721ee43c4f442e99
Author: Philip Van Hoof <philip codeminded be>
Date: Thu Apr 28 18:46:25 2011 +0200
libtracker-data, tracker-store: Improve error reporting for backup
src/libtracker-data/libtracker-data.vapi | 5 +++++
src/libtracker-data/tracker-data-backup.c | 18 ++++++++++++------
src/libtracker-data/tracker-data-backup.h | 5 +++++
src/tracker-store/tracker-backup.vala | 4 ++++
4 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-data/libtracker-data.vapi b/src/libtracker-data/libtracker-data.vapi
index ba5033b..d01f9a6 100644
--- a/src/libtracker-data/libtracker-data.vapi
+++ b/src/libtracker-data/libtracker-data.vapi
@@ -36,6 +36,11 @@ namespace Tracker {
NO_SPACE
}
+ [CCode (cprefix = "TRACKER_DATA_BACKUP_ERROR_", cheader_filename = "libtracker-data/tracker-data-backup.h")]
+ public errordomain DataBackupError {
+ INVALID_URI
+ }
+
[CCode (cprefix = "TRACKER_DB_STATEMENT_CACHE_TYPE_", cheader_filename = "libtracker-data/tracker-db-interface.h")]
public enum DBStatementCacheType {
SELECT,
diff --git a/src/libtracker-data/tracker-data-backup.c b/src/libtracker-data/tracker-data-backup.c
index 8bf0844..f37b283 100644
--- a/src/libtracker-data/tracker-data-backup.c
+++ b/src/libtracker-data/tracker-data-backup.c
@@ -205,7 +205,8 @@ process_context_child_watch_cb (GPid pid,
context = (ProcessContext *) user_data;
if (context->lines) {
- g_set_error (&error, TRACKER_DATA_BACKUP_ERROR, 0,
+ g_set_error (&error, TRACKER_DATA_BACKUP_ERROR,
+ TRACKER_DATA_BACKUP_ERROR_UNKNOWN,
"%s", context->lines->str);
}
@@ -283,7 +284,8 @@ tracker_data_backup_save (GFile *destination,
&stdout_channel,
&stderr_channel)) {
GError *error = NULL;
- g_set_error (&error, TRACKER_DATA_BACKUP_ERROR, 0,
+ g_set_error (&error, TRACKER_DATA_BACKUP_ERROR,
+ TRACKER_DATA_BACKUP_ERROR_UNKNOWN,
"Error starting tar program");
on_journal_copied (info, error);
g_strfreev (argv);
@@ -358,19 +360,22 @@ tracker_data_backup_restore (GFile *journal,
* journal, as nobody should be writing anything at this point */
if (!tracker_spawn (argv, 0, &tmp_stdout, &tmp_stderr, &exit_status)) {
- g_set_error (&info->error, TRACKER_DATA_BACKUP_ERROR, 0,
+ g_set_error (&info->error, TRACKER_DATA_BACKUP_ERROR,
+ TRACKER_DATA_BACKUP_ERROR_UNKNOWN,
"Error starting tar program");
}
if (!info->error && tmp_stderr) {
if (strlen (tmp_stderr) > 0) {
- g_set_error (&info->error, TRACKER_DATA_BACKUP_ERROR, 0,
+ g_set_error (&info->error, TRACKER_DATA_BACKUP_ERROR,
+ TRACKER_DATA_BACKUP_ERROR_UNKNOWN,
"%s", tmp_stderr);
}
}
if (!info->error && exit_status != 0) {
- g_set_error (&info->error, TRACKER_DATA_BACKUP_ERROR, 0,
+ g_set_error (&info->error, TRACKER_DATA_BACKUP_ERROR,
+ TRACKER_DATA_BACKUP_ERROR_UNKNOWN,
"Unknown error, tar exited with exit status %d", exit_status);
}
@@ -425,7 +430,8 @@ tracker_data_backup_restore (GFile *journal,
tracker_db_manager_set_need_mtime_check (TRUE);
}
} else {
- g_set_error (&info->error, TRACKER_DATA_BACKUP_ERROR, 0,
+ g_set_error (&info->error, TRACKER_DATA_BACKUP_ERROR,
+ TRACKER_DATA_BACKUP_ERROR_UNKNOWN,
"Backup file doesn't exist");
}
diff --git a/src/libtracker-data/tracker-data-backup.h b/src/libtracker-data/tracker-data-backup.h
index 072cdc5..92c0a4c 100644
--- a/src/libtracker-data/tracker-data-backup.h
+++ b/src/libtracker-data/tracker-data-backup.h
@@ -35,6 +35,11 @@ G_BEGIN_DECLS
#define TRACKER_DATA_BACKUP_ERROR_DOMAIN "TrackerBackup"
#define TRACKER_DATA_BACKUP_ERROR tracker_data_backup_error_quark()
+typedef enum {
+ TRACKER_DATA_BACKUP_ERROR_UNKNOWN = 0,
+ TRACKER_DATA_BACKUP_ERROR_INVALID_URI
+} TrackerDataBackupError;
+
typedef void (*TrackerDataBackupFinished) (GError *error, gpointer user_data);
GQuark tracker_data_backup_error_quark (void);
diff --git a/src/tracker-store/tracker-backup.vala b/src/tracker-store/tracker-backup.vala
index 49df431..f09ed6b 100644
--- a/src/tracker-store/tracker-backup.vala
+++ b/src/tracker-store/tracker-backup.vala
@@ -33,6 +33,10 @@ public class Tracker.Backup : Object {
try {
var destination = File.new_for_uri (destination_uri);
+ if (destination == null || destination.get_path() == null) {
+ throw new DataBackupError.INVALID_URI ("'" + destination_uri + "' is not a valid uri");
+ }
+
yield Tracker.Store.pause ();
Error backup_error = null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]