[balsa] Do not read config file twice



commit 879eaaea072df1db02749182284446a9ddbc8162
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon Sep 7 11:30:13 2009 -0400

    Do not read config file twice

 ChangeLog                |    5 +++++
 libbalsa/libbalsa-conf.c |   14 +++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 405aca6..9dd93a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-09-07  Peter Bloomfield
 
+	* libbalsa/libbalsa-conf.c (lbc_init): do not read config file
+	twice.
+
+2009-09-07  Peter Bloomfield
+
 	* libinit_balsa/assistant_init.c (balsa_init_begin): minimal
 	init assistant.
 	* libinit_balsa/assistant_page_user.c
diff --git a/libbalsa/libbalsa-conf.c b/libbalsa/libbalsa-conf.c
index 6441037..00f728c 100644
--- a/libbalsa/libbalsa-conf.c
+++ b/libbalsa/libbalsa-conf.c
@@ -83,16 +83,24 @@ lbc_init(LibBalsaConf * conf, const gchar * filename,
 {
     struct stat buf;
     GError *error = NULL;
+    gint rc;
 
     if (!conf->path)
         conf->path =
             g_build_filename(g_get_home_dir(), ".balsa", filename, NULL);
+    rc = stat(conf->path, &buf);
     if (conf->key_file) {
-        if (stat(conf->path, &buf) < 0 || buf.st_mtime <= conf->mtime)
+        if (rc >= 0 && buf.st_mtime <= conf->mtime)
+            /* found the config file, and it hasn't been touched since
+             * we loaded it */
             return;
-        conf->mtime = buf.st_mtime;
-    } else
+    } else {
         conf->key_file = g_key_file_new();
+        if (rc < 0)
+            /* no config file--must be first time startup */
+            return;
+    }
+    conf->mtime = buf.st_mtime;
 
     libbalsa_assure_balsa_dir();
     if (!g_key_file_load_from_file



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