[tracker] tracker-writeback: Propagate all errors of writeback over DBus



commit 6dc3f41e11702c030811c8aba50fdeb1c635de0e
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Sep 20 13:28:24 2011 +0200

    tracker-writeback: Propagate all errors of writeback over DBus
    
    All these error conditions would put miner-fs in a detect state unless
    propagated over D-Bus. Even criticals in tracker-writeback shouldn't
    leave miner-fs in a defect state (waiting for rename() to happen).

 src/tracker-writeback/tracker-writeback-file.c |   46 ++++++++++++++++++++----
 1 files changed, 39 insertions(+), 7 deletions(-)
---
diff --git a/src/tracker-writeback/tracker-writeback-file.c b/src/tracker-writeback/tracker-writeback-file.c
index 829af11..687eb80 100644
--- a/src/tracker-writeback/tracker-writeback-file.c
+++ b/src/tracker-writeback/tracker-writeback-file.c
@@ -50,8 +50,9 @@ tracker_writeback_file_init (TrackerWritebackFile *writeback_file)
 }
 
 static GFile *
-create_temporary_file (GFile     *file,
-                       GFileInfo *file_info)
+create_temporary_file (GFile      *file,
+                       GFileInfo  *file_info,
+                       GError    **in_error)
 {
 	GInputStream *input_stream;
 	GOutputStream *output_stream;
@@ -68,6 +69,12 @@ create_temporary_file (GFile     *file,
 		g_warning ("Could not create temporary file, file is not native: '%s'", uri);
 		g_free (uri);
 
+		g_set_error (in_error,
+		             G_IO_ERROR,
+		             G_IO_ERROR_FAILED,
+		             "Could not create temporary file, file is not native: '%s'",
+		             uri);
+
 		return NULL;
 	}
 
@@ -76,7 +83,7 @@ create_temporary_file (GFile     *file,
 
 	if (error) {
 		g_critical ("Could not create temporary file, %s", error->message);
-		g_error_free (error);
+		g_propagate_error (in_error, error);
 		return NULL;
 	}
 
@@ -112,8 +119,7 @@ create_temporary_file (GFile     *file,
 
 	if (error) {
 		g_critical ("Could not copy temporary file, %s", error->message);
-		g_error_free (error);
-
+		g_propagate_error (in_error, error);
 		g_file_delete (tmp_file, NULL, NULL);
 		g_object_unref (tmp_file);
 
@@ -145,12 +151,26 @@ tracker_writeback_file_update_metadata (TrackerWriteback         *writeback,
 	if (!writeback_file_class->update_file_metadata) {
 		g_critical ("%s doesn't implement update_file_metadata()",
 		            G_OBJECT_TYPE_NAME (writeback));
+
+		g_set_error (error,
+		             G_IO_ERROR,
+		             G_IO_ERROR_FAILED,
+		             "%s doesn't implement update_file_metadata()",
+		             G_OBJECT_TYPE_NAME (writeback));
+
 		return FALSE;
 	}
 
 	if (!writeback_file_class->content_types) {
 		g_critical ("%s doesn't implement content_types()",
 		            G_OBJECT_TYPE_NAME (writeback));
+
+		g_set_error (error,
+		             G_IO_ERROR,
+		             G_IO_ERROR_FAILED,
+		             "%s doesn't implement content_types()",
+		             G_OBJECT_TYPE_NAME (writeback));
+
 		return FALSE;
 	}
 
@@ -166,6 +186,13 @@ tracker_writeback_file_update_metadata (TrackerWriteback         *writeback,
 
 	if (!file_info) {
 		g_object_unref (file);
+
+		g_set_error (error,
+		             G_IO_ERROR,
+		             G_IO_ERROR_FAILED,
+		             "%s doesn't exist",
+		             row[0]);
+
 		return FALSE;
 	}
 
@@ -186,17 +213,22 @@ tracker_writeback_file_update_metadata (TrackerWriteback         *writeback,
 		g_object_unref (file_info);
 		g_object_unref (file);
 
+		g_set_error_literal (error,
+		                     G_IO_ERROR,
+		                     G_IO_ERROR_FAILED,
+		                     "Module does not support writeback for this file");
+
 		return FALSE;
 	}
 
 	/* Copy to a temporary file so we can perform an atomic write on move */
-	tmp_file = create_temporary_file (file, file_info);
+	tmp_file = create_temporary_file (file, file_info, &n_error);
 
 	g_object_unref (file_info);
 
 	if (!tmp_file) {
 		g_object_unref (file);
-
+		g_propagate_error (error, n_error);
 		return FALSE;
 	}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]