[tracker/error-handling: 6/10] libtracker-data: If unable to writer journal header, delete empty file



commit 0ddddd21ec6e7bd88f0decf90b0b367122d6289b
Author: Jürg Billeter <j bitron ch>
Date:   Tue May 17 15:21:49 2011 +0200

    libtracker-data: If unable to writer journal header, delete empty file

 src/libtracker-data/tracker-db-journal.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-journal.c b/src/libtracker-data/tracker-db-journal.c
index 4d6ce74..fc5956a 100644
--- a/src/libtracker-data/tracker-db-journal.c
+++ b/src/libtracker-data/tracker-db-journal.c
@@ -495,6 +495,11 @@ db_journal_init_file (JournalWriter  *jwriter,
 		jwriter->cur_block[7] = '4';
 
 		if (!write_all_data (jwriter->journal, jwriter->cur_block, 8, error)) {
+			cur_block_kill (jwriter);
+			/* delete empty journal file */
+			g_unlink (jwriter->journal_filename);
+			close (jwriter->journal);
+			jwriter->journal = 0;
 			return FALSE;
 		}
 



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