[gcompris] core: added the command line option --disable-database
- From: Bruno Coudoin <bcoudoin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcompris] core: added the command line option --disable-database
- Date: Fri, 4 May 2012 22:43:20 +0000 (UTC)
commit c5c7dcfce518ab141d4c6c62e757823592dc7693
Author: Bruno Coudoin <bruno coudoin free fr>
Date: Sat May 5 00:37:26 2012 +0200
core: added the command line option --disable-database
In some case it may be usefull to run without the database.
I expect it usefull to debug startup issues on Windows.
src/gcompris/gcompris.c | 14 +++++++++++++-
src/gcompris/gcompris_db.c | 11 +++++++++--
2 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/src/gcompris/gcompris.c b/src/gcompris/gcompris.c
index 6df719e..13e43cd 100644
--- a/src/gcompris/gcompris.c
+++ b/src/gcompris/gcompris.c
@@ -140,6 +140,7 @@ static gint popt_experimental = FALSE;
static gint popt_no_quit = FALSE;
static gint popt_no_config = FALSE;
static gint popt_no_level = FALSE;
+static gint popt_no_database = FALSE;
static gchar *popt_server = NULL;
static gint *popt_web_only = NULL;
static gchar *popt_cache_dir = NULL;
@@ -237,6 +238,9 @@ static GOptionEntry options[] = {
{"disable-level",'\0', 0, G_OPTION_ARG_NONE, &popt_no_level,
N_("Disable the level button"), NULL},
+ {"disable-database",'\0', 0, G_OPTION_ARG_NONE, &popt_no_database,
+ N_("Disable the database (slower start and no user log)"), NULL},
+
{"server", '\0', 0, G_OPTION_ARG_STRING, &popt_server,
N_("GCompris will get images, sounds and activity data from this server if not found locally."), NULL},
@@ -1756,6 +1760,12 @@ main (int argc, char *argv[])
properties->disable_level = TRUE;
}
+ if (popt_no_database)
+ {
+ g_message("Disable database");
+ gc_db_init(TRUE /* DISABLE DATABASE */);
+ }
+
if (popt_difficulty_filter>=0)
{
/* This option provide less capacity than the GUI since we cannot set the filter_style */
@@ -1981,7 +1991,9 @@ main (int argc, char *argv[])
*/
if (popt_root_menu)
gc_db_init(TRUE /* DISABLE DATABASE */);
- else
+ else if (popt_no_database)
+ gc_db_init(TRUE /* DISABLE DATABASE */);
+ else
gc_db_init(FALSE /* ENABLE DATABASE */);
/* An alternate profile is requested, check it does exists */
diff --git a/src/gcompris/gcompris_db.c b/src/gcompris/gcompris_db.c
index 8664d70..be71649 100644
--- a/src/gcompris/gcompris_db.c
+++ b/src/gcompris/gcompris_db.c
@@ -430,8 +430,15 @@ gboolean gc_db_init(gboolean disable_database_)
// backup it and re create it.
sqlite3_close(gcompris_db);
gchar *backup = g_strdup_printf("%s.broken", properties->database);
- g_rename(properties->database, backup);
- g_message("Database is broken, it is copyed in %s", backup);
+ if ( g_rename(properties->database, backup) < 0 )
+ {
+ // Obviously, we cannot write the backup file either
+ g_message("Failed to write the backup database %s", backup);
+ disable_database = TRUE;
+ return FALSE;
+ }
+ else
+ g_message("Database is broken, it is copyed in %s", backup);
g_free(backup);
rc = sqlite3_open(properties->database, &gcompris_db);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]