[tracker/tracker-0.6] Removing the database file when it's corrupted, just before we bail out and crash



commit 0c8078dffc23287df629eac7e61357f7cdcbc449
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed Apr 15 12:00:42 2009 +0200

    Removing the database file when it's corrupted, just before we bail out and crash
---
 src/libtracker-db/tracker-db-interface-sqlite.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/libtracker-db/tracker-db-interface-sqlite.c b/src/libtracker-db/tracker-db-interface-sqlite.c
index 8693398..112d69b 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.c
+++ b/src/libtracker-db/tracker-db-interface-sqlite.c
@@ -18,7 +18,9 @@
  * Boston, MA  02110-1301, USA.
  */
 
+#include <glib/gstdio.h>
 #include <sqlite3.h>
+
 #include "tracker-db-interface-sqlite.h"
 
 #define TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_DB_INTERFACE_SQLITE, TrackerDBInterfaceSqlitePrivate))
@@ -556,9 +558,11 @@ create_result_set_from_stmt (TrackerDBInterfaceSqlite  *interface,
 		g_hash_table_foreach (priv->statements, foreach_print_error, stmt);
 
 		if (result == SQLITE_CORRUPT) {
-			g_critical ("Sqlite3 database:'%s' is corrupt, can not live without it",
-				    priv->filename);
-			g_assert_not_reached ();
+			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);
 		}
 
 		if (!error) {



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