disables automatic creation of .dav directory in dav

Tue, 03 Oct 2017 14:59:35 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 03 Oct 2017 14:59:35 +0200
changeset 319
2433b5969d44
parent 318
7e0694423838
child 320
12ed560c926c

disables automatic creation of .dav directory in dav

dav/config.c file | annotate | diff | comparison | revisions
dav/config.h file | annotate | diff | comparison | revisions
dav/scfg.c file | annotate | diff | comparison | revisions
dav/version.h file | annotate | diff | comparison | revisions
--- a/dav/config.c	Sun Oct 01 17:37:59 2017 +0200
+++ b/dav/config.c	Tue Oct 03 14:59:35 2017 +0200
@@ -99,9 +99,6 @@
     // TODO: free the config somewhere
     repos = ucx_map_new(16);
     keys = ucx_map_new(16);
-    if(check_config_dir()) {
-        return 1;
-    }
     
     char *file = util_concat_path(ENV_HOME, ".dav/config.xml");
     
@@ -109,7 +106,6 @@
     if(stat(file, &s)) {
         switch(errno) {
             case ENOENT: {
-                create_default_config(file);
                 return 0;
             }
             default: {
@@ -589,7 +585,27 @@
 }
 
 int add_repository(Repository *repo) {
+    if(check_config_dir()) {
+        fprintf(stderr, "Cannot create .dav directory\n");
+        return 1;
+    }
+    
     char *file = util_concat_path(ENV_HOME, ".dav/config.xml");
+    struct stat s;
+    if(stat(file, &s)) {
+        switch(errno) {
+            case ENOENT: {
+                create_default_config(file);
+                break;
+            }
+            default: {
+                perror("Cannot load config.xml");
+                free(file);
+                return 1;
+            }
+        }
+    }
+    
     xmlDoc *doc = xmlReadFile(file, NULL, 0);
     if(!doc) {
         free(file);
--- a/dav/config.h	Sun Oct 01 17:37:59 2017 +0200
+++ b/dav/config.h	Tue Oct 03 14:59:35 2017 +0200
@@ -67,6 +67,8 @@
     unsigned long authmethods;
 };
 
+int check_config_dir(void);
+
 char* config_file_path(char *name);
     
 int load_config(DavContext *ctx);
--- a/dav/scfg.c	Sun Oct 01 17:37:59 2017 +0200
+++ b/dav/scfg.c	Tue Oct 03 14:59:35 2017 +0200
@@ -35,6 +35,7 @@
 #include <ucx/utils.h>
 
 #include "scfg.h"
+#include "config.h"
 
 #define xstreq(a,b) xmlStrEqual(BAD_CAST a, BAD_CAST b)
 
@@ -273,6 +274,11 @@
 int load_sync_config() {
     directories = ucx_map_new(8);
     
+    if(check_config_dir()) {
+        fprintf(stderr, "Cannot create .dav directory\n");
+        return 1;
+    }
+    
     char *file = util_concat_path(ENV_HOME, ".dav/sync.xml");
     
     struct stat s;
--- a/dav/version.h	Sun Oct 01 17:37:59 2017 +0200
+++ b/dav/version.h	Tue Oct 03 14:59:35 2017 +0200
@@ -29,7 +29,7 @@
 #ifndef VERSION_H
 #define VERSION_H
 
-#define DAV_VERSION "1.0 dev"
+#define DAV_VERSION "1.1 RC1"
 
 #endif /* VERSION_H */
 

mercurial