gnucash master: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Fri Dec 26 16:08:00 EST 2014


Updated	 via  https://github.com/Gnucash/gnucash/commit/9b1d8d15 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d5ade4cb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/24dff859 (commit)
	from  https://github.com/Gnucash/gnucash/commit/cac89600 (commit)



commit 9b1d8d150f772cba512f65d0c93d7ab502fa6813
Merge: cac8960 d5ade4c
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Dec 26 13:32:57 2014 -0800

    Merge branch 'maint'


commit d5ade4cbc080483be77a1b9aa9a04e06f9ba3ddf
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Dec 26 13:28:22 2014 -0800

    Fix typo in Transaction.c.
    
    Thanks to Christoph Holterman for catching this.

diff --git a/src/engine/Transaction.c b/src/engine/Transaction.c
index d90a47c..eac94d6 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 <gnc-gdate-utils.h>
-#include "SchedXAction.h"
+#include "SchedXaction.h"
 #include "qofbackend-p.h"
 
 /* Notes about xaccTransBeginEdit(), xaccTransCommitEdit(), and

commit 24dff8598599cb9979924b9226f1c7acabc7a6bd
Author: Geert Janssens <janssens-geert at telenet.be>
Date:   Wed Dec 24 12:49:46 2014 +0100

    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.

diff --git a/src/core-utils/gnc-filepath-utils.c b/src/core-utils/gnc-filepath-utils.c
index 54cdc18..11d5ecf 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);
 



Summary of changes:
 src/core-utils/gnc-filepath-utils.c | 57 ++++++++++++++++++++++++++-----------
 src/engine/Transaction.c            |  2 +-
 2 files changed, 41 insertions(+), 18 deletions(-)



More information about the gnucash-changes mailing list