[tracker/tracker-0.10] tracker-writeback: preserve original file if writeback fails



commit a3f7723398af26f7a1fd60ba0c0072cb70e1b37f
Author: Carlos Garnacho <carlos lanedo com>
Date:   Fri Jul 29 14:41:18 2011 +0200

    tracker-writeback: preserve original file if writeback fails
    
    The temporary file is now deleted instead, leaving the original
    file unmodified.

 src/tracker-writeback/tracker-writeback-file.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/tracker-writeback/tracker-writeback-file.c b/src/tracker-writeback/tracker-writeback-file.c
index 7b5bef9..34e44f1 100644
--- a/src/tracker-writeback/tracker-writeback-file.c
+++ b/src/tracker-writeback/tracker-writeback-file.c
@@ -200,10 +200,15 @@ tracker_writeback_file_update_metadata (TrackerWriteback        *writeback,
 	                                                       connection,
 	                                                       cancellable);
 
-	/* Move back the modified file to the original location */
-	g_file_move (tmp_file, file,
-	             G_FILE_COPY_OVERWRITE,
-	             NULL, NULL, NULL, NULL);
+	if (!retval) {
+		/* Delete the temporary file and preserve original */
+		g_file_delete (tmp_file, NULL, NULL);
+	} else {
+		/* Move back the modified file to the original location */
+		g_file_move (tmp_file, file,
+			     G_FILE_COPY_OVERWRITE,
+			     NULL, NULL, NULL, NULL);
+	}
 
 	g_object_unref (tmp_file);
 	g_object_unref (file);



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