From 24dff8598599cb9979924b9226f1c7acabc7a6bd Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Wed, 24 Dec 2014 12:49:46 +0100 Subject: [PATCH 1/2] Revisit "Bug 741810 - Compilation fails because of creating .gnucash" Use the temp dir as base dir for .gnucash in all cases where the home dir fails. This is more than just if the home directory doesn't exist. Also don't attempt to create the home directory. --- src/core-utils/gnc-filepath-utils.c | 57 ++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/src/core-utils/gnc-filepath-utils.c b/src/core-utils/gnc-filepath-utils.c index 54cdc187ea..11d5ecfdeb 100644 --- a/src/core-utils/gnc-filepath-utils.c +++ b/src/core-utils/gnc-filepath-utils.c @@ -300,7 +300,7 @@ gnc_path_find_localized_html_file (const gchar *file_name) * @param dirname The path to check */ static gboolean -gnc_validate_directory (const gchar *dirname, gchar **msg) +gnc_validate_directory (const gchar *dirname, gboolean create, gchar **msg) { struct stat statbuf; gint rc; @@ -312,21 +312,33 @@ gnc_validate_directory (const gchar *dirname, gchar **msg) switch (errno) { case ENOENT: - rc = g_mkdir (dirname, + if (create) + { + rc = g_mkdir (dirname, #ifdef G_OS_WIN32 - 0 /* The mode argument is ignored on windows */ + 0 /* The mode argument is ignored on windows */ #else - S_IRWXU /* perms = S_IRWXU = 0700 */ + S_IRWXU /* perms = S_IRWXU = 0700 */ #endif - ); - if (rc) + ); + if (rc) + { + *msg = g_strdup_printf( + _("An error occurred while creating the directory:\n" + " %s\n" + "Please correct the problem and restart GnuCash.\n" + "The reported error was '%s' (errno %d).\n"), + dirname, g_strerror(errno) ? g_strerror(errno) : "", errno); + return FALSE; + } + } + else { *msg = g_strdup_printf( - _("An error occurred while creating the directory:\n" - " %s\n" - "Please correct the problem and restart GnuCash.\n" - "The reported error was '%s' (errno %d).\n"), - dirname, g_strerror(errno) ? g_strerror(errno) : "", errno); + _("Note: the directory\n" + " %s\n" + "doesn't exist. This is however not fatal.\n"), + dirname); return FALSE; } g_stat (dirname, &statbuf); @@ -412,7 +424,7 @@ gnc_dotgnucash_dir (void) if (!dotgnucash) { const gchar *home = g_get_home_dir(); - if (!home || !gnc_validate_directory(home, &errmsg)) + if (!home || !gnc_validate_directory(home, FALSE, &errmsg)) { g_free(errmsg); g_warning("Cannot find suitable home directory. Using tmp directory instead."); @@ -422,20 +434,31 @@ gnc_dotgnucash_dir (void) dotgnucash = g_build_filename(home, ".gnucash", (gchar *)NULL); } - if (!gnc_validate_directory(dotgnucash, &errmsg)) - exit(1); + if (!gnc_validate_directory(dotgnucash, TRUE, &errmsg)) + { + const gchar *tmp = g_get_tmp_dir(); + g_free(errmsg); + g_free(dotgnucash); + g_warning("Cannot find suitable .gnucash directory in home directory. Using tmp directory instead."); + g_assert(tmp); + + dotgnucash = g_build_filename(tmp, ".gnucash", (gchar *)NULL); + + if (!gnc_validate_directory(dotgnucash, TRUE, &errmsg)) + exit(1); + } /* Since we're in code that is only executed once.... */ tmp_dir = g_build_filename(dotgnucash, "books", (gchar *)NULL); - if (!gnc_validate_directory(tmp_dir, &errmsg)) + if (!gnc_validate_directory(tmp_dir, TRUE, &errmsg)) exit(1); g_free(tmp_dir); tmp_dir = g_build_filename(dotgnucash, "checks", (gchar *)NULL); - if (!gnc_validate_directory(tmp_dir, &errmsg)) + if (!gnc_validate_directory(tmp_dir, TRUE, &errmsg)) exit(1); g_free(tmp_dir); tmp_dir = g_build_filename(tmp_dir, "translog", (gchar *)NULL); - if (!gnc_validate_directory(dotgnucash, &errmsg)) + if (!gnc_validate_directory(dotgnucash, TRUE, &errmsg)) exit(1); g_free(tmp_dir); From d5ade4cbc080483be77a1b9aa9a04e06f9ba3ddf Mon Sep 17 00:00:00 2001 From: John Ralls Date: Fri, 26 Dec 2014 13:28:22 -0800 Subject: [PATCH 2/2] Fix typo in Transaction.c. Thanks to Christoph Holterman for catching this. --- src/engine/Transaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/Transaction.c b/src/engine/Transaction.c index d90a47cf8f..eac94d6627 100644 --- a/src/engine/Transaction.c +++ b/src/engine/Transaction.c @@ -58,7 +58,7 @@ struct timeval #include "gnc-lot.h" #include "gnc-event.h" #include -#include "SchedXAction.h" +#include "SchedXaction.h" #include "qofbackend-p.h" /* Notes about xaccTransBeginEdit(), xaccTransCommitEdit(), and