diff -r 1f76d9624db8 -r bc2cdbf5e68f dav/sync.c --- a/dav/sync.c Thu Aug 15 20:25:21 2019 +0200 +++ b/dav/sync.c Sun Aug 18 09:41:29 2019 +0200 @@ -2521,14 +2521,18 @@ } char *new_path = util_concat_path(p, ent->name); + DavBool free_new_path = TRUE; LocalResource *res = local_resource_new(dir, db, new_path); - if(res->isdirectory) { - resources = ucx_list_append(resources, res); - stack = ucx_list_prepend(stack, new_path); - } else if(res) { - resources = ucx_list_append(resources, res); - free(new_path); - } else { + if(res) { + if(res->isdirectory) { + resources = ucx_list_append(resources, res); + stack = ucx_list_prepend(stack, new_path); + free_new_path = FALSE; + } else { + resources = ucx_list_append(resources, res); + } + } + if(free_new_path) { free(new_path); } } @@ -2609,6 +2613,7 @@ res->isdirectory = 1; } + int skip_file = 0; if(SYS_ISLINK(file_path, s)) { char *lnkbuf = sys_readlink(file_path, &s); #ifdef SYS_LINK_EXT @@ -2653,10 +2658,31 @@ } char *dirpath = util_path_normalize(dir->path); - if(util_path_isrelated(dirpath, normalized)) { + int isintern = util_path_isrelated(dirpath, normalized); + + + if(SYNC_SYMLINK(dir) && isintern) { // the link points to a file inside the syncdir char *rel = util_create_relative_path(normalized, file_path); res->link_target = rel; + } else { +#ifndef SYS_LINK_EXT // if not windows + SYS_STAT targetstat; + 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; + if(isintern && nofollowintern) { + skip_file = TRUE; + } else if(!isintern && nofollowextern) { + skip_file = TRUE; + } + } else { + // can't access target, therefore we skip this link + skip_file = TRUE; + } +#endif } free(dirpath); free(normalized); @@ -2666,6 +2692,11 @@ free(file_path); + if(skip_file) { + local_resource_free(res); + res = NULL; + } + return res; } @@ -2808,6 +2839,10 @@ return 0; } + if(remote->iscollection) { + return 1; + } + int ret = 0; if(err == 0) { char *etag = dav_get_string_property(remote, "D:getetag"); @@ -3197,6 +3232,7 @@ if(local) { if(local->tags_hash) { free(local->tags_hash); + local->tags_hash = NULL; } local->tags_hash = data_hash; } @@ -3276,6 +3312,7 @@ *changed = TRUE; } free(res->tags_hash); + res->tags_hash = NULL; } else { if(changed) *changed = TRUE; } @@ -3460,6 +3497,7 @@ if(hashes.tags) { if(local->tags_hash) { free(local->tags_hash); + local->tags_hash = NULL; } local->tags_hash = hashes.tags; } @@ -4764,6 +4802,7 @@ if(!tags) { if(localres->tags_hash) { free(localres->tags_hash); + localres->tags_hash = NULL; } localres->tags_hash = NULL; }