# HG changeset patch # User Olaf Wintermann # Date 1568748096 -7200 # Node ID a38b1506184878cc49f5e3f5b86aedf9576c9039 # Parent 5b8643cf0a2ffbd762a7add16daab09736874d9d refactore symlink config diff -r 5b8643cf0a2f -r a38b15061848 dav/scfg.c --- a/dav/scfg.c Tue Sep 17 21:06:03 2019 +0200 +++ b/dav/scfg.c Tue Sep 17 21:21:36 2019 +0200 @@ -501,23 +501,30 @@ pushstrat = PUSH_STRATEGY_HASH; } } - } 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); + } else if(xstreq(node->name, "symlink-intern")) { + if(!value) { + print_error(node->line, "missing value"); + } else if(xstreq(value, "sync")) { + symlink |= SYNC_SYMLINK_SYNC; + } else if(xstreq(value, "follow")) { + // nothing, default + } else if(xstreq(value, "ignore")) { + symlink |= SYNC_SYMLINK_IGNORE_INTERN; + } else { + print_error(node->line, + "unknown value: %s\n", value); } - free(cmdstr); - symlink = symlinkconfig; + } else if(xstreq(node->name, "symlink-extern")) { + if(!value) { + print_error(node->line, "missing value"); + } else if(xstreq(value, "follow")) { + // nothing, default + } else if(xstreq(value, "ignore")) { + symlink |= SYNC_SYMLINK_IGNORE_EXTERN; + } else { + print_error(node->line, + "unknown value: %s\n", value); + } } else { print_error(node->line, "unknown directory config element: %s\n", node->name); diff -r 5b8643cf0a2f -r a38b15061848 dav/scfg.h --- a/dav/scfg.h Tue Sep 17 21:06:03 2019 +0200 +++ b/dav/scfg.h Tue Sep 17 21:21:36 2019 +0200 @@ -46,9 +46,9 @@ #define SYNC_CMD_ARCHIVE 4 #define SYNC_CMD_RESTORE 8 -#define SYNC_SYMLINK_SYNC 1 -#define SYNC_SYMLINK_EXTERN_NOFOLLOW 2 -#define SYNC_SYMLINK_INTERN_NOFOLLOW 4 +#define SYNC_SYMLINK_SYNC 1 +#define SYNC_SYMLINK_IGNORE_EXTERN 2 +#define SYNC_SYMLINK_IGNORE_INTERN 4 #define DEFAULT_TAG_XATTR "tags" #define MACOS_TAG_XATTR "com.apple.metadata:_kMDItemUserTags" diff -r 5b8643cf0a2f -r a38b15061848 dav/sync.c --- a/dav/sync.c Tue Sep 17 21:06:03 2019 +0200 +++ b/dav/sync.c Tue Sep 17 21:21:36 2019 +0200 @@ -2683,8 +2683,8 @@ if(!sys_stat(file_path, &targetstat)) { res->isdirectory = S_ISDIR(targetstat.st_mode); - int nofollowextern = (dir->symlink & SYNC_SYMLINK_EXTERN_NOFOLLOW) == SYNC_SYMLINK_EXTERN_NOFOLLOW; - int nofollowintern = (dir->symlink & SYNC_SYMLINK_INTERN_NOFOLLOW) == SYNC_SYMLINK_INTERN_NOFOLLOW; + int nofollowextern = (dir->symlink & SYNC_SYMLINK_IGNORE_EXTERN) == SYNC_SYMLINK_IGNORE_EXTERN; + int nofollowintern = (dir->symlink & SYNC_SYMLINK_IGNORE_INTERN) == SYNC_SYMLINK_IGNORE_INTERN; if(isintern && nofollowintern) { skip_file = TRUE; } else if(!isintern && nofollowextern) {