[tracker/tracker-0.6] Fixes: NB#108361, Tracker crashing if commo.db is corrupt



commit 403cdca89effc98f4d92b27d56d4319120d108c6
Author: Ivan Frade <ivan frade nokia com>
Date:   Thu Apr 16 13:55:20 2009 +0100

    Fixes: NB#108361, Tracker crashing if commo.db is corrupt
---
 src/libtracker-db/tracker-db-interface-sqlite.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/libtracker-db/tracker-db-interface-sqlite.c b/src/libtracker-db/tracker-db-interface-sqlite.c
index 112d69b..fd4827f 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.c
+++ b/src/libtracker-db/tracker-db-interface-sqlite.c
@@ -554,19 +554,30 @@ create_result_set_from_stmt (TrackerDBInterfaceSqlite  *interface,
 	}
 
 	if (result != SQLITE_DONE) {
-
 		g_hash_table_foreach (priv->statements, foreach_print_error, stmt);
 
-		if (result == SQLITE_CORRUPT) {
+		/* This is rather fatal */
+		if (sqlite3_errcode (priv->db) == SQLITE_IOERR ||
+		    sqlite3_errcode (priv->db) == SQLITE_CORRUPT ||
+		    sqlite3_errcode (priv->db) == SQLITE_NOTADB) {
 			sqlite3_finalize (stmt);
 			sqlite3_close (priv->db);
+			
 			g_unlink (priv->filename);
-			g_error ("SQLite database:'%s' has been corrupted and removed, it will be recreated on restart, shutting down now",
-				  priv->filename);
+			
+			g_error ("SQLite experienced an error with file:'%s'. "
+				 "It is either NOT a SQLite database or it is "
+				 "corrupt or there was an IO error accessing the data. "
+				 "This file has now been removed and will be recreated on the next start. "
+				 "Shutting down now.",
+				 priv->filename);
+			return NULL;
 		}
 
 		if (!error) {
-			g_warning ("%s", sqlite3_errmsg (priv->db));
+			g_warning ("Could not perform SQLite operation, error:%d->'%s'",
+				   sqlite3_errcode (priv->db),
+				   sqlite3_errmsg (priv->db));
 		} else {
 			g_set_error (error,
 				     TRACKER_DB_INTERFACE_ERROR,



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