add element for configuring symlinks

Sun, 11 Aug 2019 18:41:06 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 11 Aug 2019 18:41:06 +0200
changeset 623
7870656d302d
parent 622
6524f45f304e
child 624
27985062cd2c

add element for configuring symlinks

dav/scfg.c file | annotate | diff | comparison | revisions
dav/scfg.h file | annotate | diff | comparison | revisions
--- a/dav/scfg.c	Sun Aug 11 11:27:04 2019 +0200
+++ b/dav/scfg.c	Sun Aug 11 18:41:06 2019 +0200
@@ -393,9 +393,10 @@
     bool lockpull = false;
     bool lockpush = false;
     bool hashing = false;
-    bool detect_copy = false;
+    //bool detect_copy = false;
     time_t lock_timeout = 0;
     uint32_t metadata = 0;
+    uint32_t symlink = 0;
     
     unsigned short parentlineno = node->line;
     node = node->children;
@@ -489,6 +490,23 @@
                 }
             } else if(xstreq(node->name, "hashing")) {
                 hashing = util_getboolean(value);
+            } else if(xstreq(node->name, "symlinks")) {
+                uint32_t symlinkconfig = 0;
+                const char *delims = " ,\r\n";
+                char *cmdstr = strdup(value);
+                char *s = strtok(cmdstr, delims);
+                while(s) {
+                    if(!strcmp(s, "sync")) {
+                        symlinkconfig |= SYNC_SYMLINK_SYNC;
+                    } else if(!strcmp(s, "extern_nofollow")) {
+                        symlinkconfig |= SYNC_SYMLINK_EXTERN_NOFOLLOW;
+                    } else if(!strcmp(s, "intern_nofollow")) {
+                        symlinkconfig |= SYNC_SYMLINK_INTERN_NOFOLLOW;
+                    }
+                    s = strtok(NULL, delims);
+                }
+                free(cmdstr);
+                symlink = symlinkconfig;
             } else {
                 print_error(node->line,
                         "unknown directory config element: %s\n", node->name);
@@ -535,7 +553,7 @@
     dir->lock_timeout = lock_timeout;
     dir->metadata = metadata;
     dir->splitconfig = splitconfig;
-    dir->symlink = SYNC_SYMLINK_STORE; // TODO: add config elements
+    dir->symlink = symlink;
     if((metadata & FINFO_MODE) == FINFO_MODE) {
         dir->db_settings = DB_STORE_MODE;
     }
--- a/dav/scfg.h	Sun Aug 11 11:27:04 2019 +0200
+++ b/dav/scfg.h	Sun Aug 11 18:41:06 2019 +0200
@@ -46,7 +46,7 @@
 #define SYNC_CMD_ARCHIVE 4
 #define SYNC_CMD_RESTORE 8
     
-#define SYNC_SYMLINK_STORE 1
+#define SYNC_SYMLINK_SYNC            1
 #define SYNC_SYMLINK_EXTERN_NOFOLLOW 2
 #define SYNC_SYMLINK_INTERN_NOFOLLOW 4
     
@@ -54,7 +54,7 @@
 #define MACOS_TAG_XATTR "com.apple.metadata:_kMDItemUserTags"
     
 #define SYNC_SYMLINK(dir) \
-    (((dir)->symlink & SYNC_SYMLINK_STORE) == SYNC_SYMLINK_STORE)
+    (((dir)->symlink & SYNC_SYMLINK_SYNC) == SYNC_SYMLINK_SYNC)
     
 typedef struct TagConfig   TagConfig;
 typedef struct Versioning  Versioning;
@@ -76,7 +76,7 @@
     uint32_t metadata;
     int max_retry;
     int allow_cmd;
-    int symlink;
+    uint32_t symlink;
     time_t lock_timeout;
     bool backuppull;
     bool lockpull;

mercurial