# HG changeset patch # User Olaf Wintermann # Date 1527837831 -7200 # Node ID babdf40dd22c02e0e47d176675233b354426faa8 # Parent 3bb3210f3e6eec9de9bb8d2fecefaecb4d394017 dav-sync pull applies config tag filter now also changes, that include/exclude filters never lead to file deletion diff -r 3bb3210f3e6e -r babdf40dd22c dav/scfg.c --- a/dav/scfg.c Fri Jun 01 09:07:20 2018 +0200 +++ b/dav/scfg.c Fri Jun 01 09:23:51 2018 +0200 @@ -394,6 +394,7 @@ regcomp(matchnothing, "///", REG_NOSUB); dir->exclude = ucx_list_append(NULL, matchnothing); } + dir->tagfilter = tagfilter; if (trash && sstrtrim(sstr(trash)).length > 0) { if (trash[0] == '/' || trash[0] == '$') { diff -r 3bb3210f3e6e -r babdf40dd22c dav/scfg.h --- a/dav/scfg.h Fri Jun 01 09:07:20 2018 +0200 +++ b/dav/scfg.h Fri Jun 01 09:23:51 2018 +0200 @@ -60,6 +60,7 @@ TagConfig *tagconfig; UcxList *include; UcxList *exclude; + SyncTagFilter *tagfilter; int max_retry; int allow_cmd; time_t lock_timeout; diff -r 3bb3210f3e6e -r babdf40dd22c dav/sync.c --- a/dav/sync.c Fri Jun 01 09:07:20 2018 +0200 +++ b/dav/sync.c Fri Jun 01 09:23:51 2018 +0200 @@ -258,6 +258,10 @@ } static int res_matches_tags(DavResource *res, SyncTagFilter *tagfilter) { + if(!tagfilter) { + return 1; + } + if(tagfilter->mode == DAV_SYNC_TAGFILTER_OFF) { return 1; } @@ -441,6 +445,8 @@ return -1; } + DavBool remove_file = cmd_getoption(a, "remove") ? 1 : 0; + int sync_success = 0; int sync_delete = 0; int sync_error = 0; @@ -455,13 +461,17 @@ stack = ucx_list_remove(stack, stack); while(res) { - if (res_matches_filter(dir, res->path)) { + if ( res_matches_filter(dir, res->path) + || !res_matches_tags(res, dir->tagfilter)) + { + // don't delete files filtered by config + localres_keep(db, res->path); res = res->next; continue; } - + if (!res_matches_tags(res, tagfilter)) { - if(!cmd_getoption(a, "remove")) { + if(!remove_file) { localres_keep(db, res->path); } res = res->next;