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;