# HG changeset patch # User Olaf Wintermann # Date 1528901876 -7200 # Node ID f340460a8b5dcb58f73c62a7034287ba9d2ea6fa # Parent d7a086201a6e65d2020a71b236fdfd90ef30202a disables tagfilter for directories diff -r d7a086201a6e -r f340460a8b5d dav/scfg.c --- a/dav/scfg.c Tue Jun 12 11:14:16 2018 +0200 +++ b/dav/scfg.c Wed Jun 13 16:57:56 2018 +0200 @@ -96,7 +96,7 @@ xmlNode *node, UcxList **include, UcxList **exclude, - SyncTagFilter **tagfilter) + UcxList **tags) { node = node->children; @@ -113,9 +113,9 @@ } } else if(xstreq(node->name, "tags")) { if(value) { - *tagfilter = parse_tagfilter_string( + SyncTagFilter *tagfilter = parse_tagfilter_string( value, DAV_SYNC_TAGFILTER_SCOPE_RESOURCE); - if(!*tagfilter) { + if(!tagfilter) { print_error( node->line, "malformed tag filter: %s\n", @@ -127,18 +127,23 @@ if(scope) { if(xstreq(scope, "resource")) { - (*tagfilter)->scope = + tagfilter->scope = DAV_SYNC_TAGFILTER_SCOPE_RESOURCE; } else if(xstreq(scope, "collection")) { - (*tagfilter)->scope = + tagfilter->scope = DAV_SYNC_TAGFILTER_SCOPE_COLLECTION; } else if(xstreq(scope, "all")) { - (*tagfilter)->scope = + tagfilter->scope = DAV_SYNC_TAGFILTER_SCOPE_RESOURCE | DAV_SYNC_TAGFILTER_SCOPE_COLLECTION; + } else { + tagfilter->scope = + DAV_SYNC_TAGFILTER_SCOPE_RESOURCE; } } xmlFree(scope); + + *tags = ucx_list_append(*tags, tagfilter); } } } else { @@ -257,7 +262,7 @@ TagConfig *tagconfig = NULL; UcxList *include = NULL; UcxList *exclude = NULL; - SyncTagFilter *tagfilter = NULL; + UcxList *tagfilter = NULL; int max_retry = 0; int allow_cmd = SYNC_CMD_PULL | SYNC_CMD_PUSH | SYNC_CMD_ARCHIVE; bool backuppull = false; diff -r d7a086201a6e -r f340460a8b5d dav/scfg.h --- a/dav/scfg.h Tue Jun 12 11:14:16 2018 +0200 +++ b/dav/scfg.h Wed Jun 13 16:57:56 2018 +0200 @@ -60,7 +60,7 @@ TagConfig *tagconfig; UcxList *include; UcxList *exclude; - SyncTagFilter *tagfilter; + UcxList *tagfilter; int max_retry; int allow_cmd; time_t lock_timeout; diff -r d7a086201a6e -r f340460a8b5d dav/sync.c --- a/dav/sync.c Tue Jun 12 11:14:16 2018 +0200 +++ b/dav/sync.c Wed Jun 13 16:57:56 2018 +0200 @@ -262,10 +262,14 @@ if(!tagfilter || tagfilter->mode == DAV_SYNC_TAGFILTER_OFF) { return 1; } - int scope = res->iscollection ? - DAV_SYNC_TAGFILTER_SCOPE_COLLECTION - : DAV_SYNC_TAGFILTER_SCOPE_RESOURCE; - if(tagfilter->scope & scope != scope) { + // NOTE: currently not implementable + //int scope = res->iscollection ? + // DAV_SYNC_TAGFILTER_SCOPE_COLLECTION + // : DAV_SYNC_TAGFILTER_SCOPE_RESOURCE; + //if((tagfilter->scope & scope) != scope) { + // return 1; + //} + if(res->iscollection) { return 1; } @@ -288,10 +292,13 @@ if(!tagfilter || tagfilter->mode == DAV_SYNC_TAGFILTER_OFF) { return 1; } - int scope = res->isdirectory ? - DAV_SYNC_TAGFILTER_SCOPE_COLLECTION - : DAV_SYNC_TAGFILTER_SCOPE_RESOURCE; - if(tagfilter->scope & scope != scope) { + //int scope = res->isdirectory ? + // DAV_SYNC_TAGFILTER_SCOPE_COLLECTION + // : DAV_SYNC_TAGFILTER_SCOPE_RESOURCE; + //if((tagfilter->scope & scope) != scope) { + // return 1; + //} + if(res->isdirectory) { return 1; } @@ -482,9 +489,19 @@ stack = ucx_list_remove(stack, stack); while(res) { - if ( res_matches_filter(dir, res->path) - || !res_matches_tags(res, dir->tagfilter)) - { + DavBool res_filtered = FALSE; + if (res_matches_filter(dir, res->path)) { + res_filtered = TRUE; + } else { + UCX_FOREACH(elm, dir->tagfilter) { + SyncTagFilter *tf = elm->data; + if(!res_matches_tags(res, tf)) { + res_filtered = TRUE; + break; + } + } + } + if(res_filtered) { // don't delete files filtered by config localres_keep(db, res->path); res = res->next; @@ -1026,9 +1043,19 @@ LocalResource *local_res = elm->data; int error = 0; - if ( res_matches_filter(dir, local_res->path+1) - || !localres_matches_tags(dir, local_res, dir->tagfilter)) - { + DavBool res_filtered = FALSE; + if(res_matches_filter(dir, local_res->path+1)) { + res_filtered = TRUE; + } else { + UCX_FOREACH(elm, dir->tagfilter) { + SyncTagFilter *tf = elm->data; + if(!localres_matches_tags(dir, local_res, tf)) { + res_filtered = TRUE; + break; + } + } + } + if (res_filtered) { local_res->keep = TRUE; } else if (!localres_matches_tags(dir, local_res, tagfilter)) { if(!remove_file) { @@ -1137,7 +1164,7 @@ UcxMapIterator i = ucx_map_iterator(db->resources); LocalResource *local; UCX_MAP_FOREACH(key, local, i) { - if (!local->keep) { + if (!local->keep && !res_matches_filter(dir, local->path+1)) { if(sync_shutdown) { ucx_map_cstr_put(lclres, local->path, local_resource_copy(local)); } else if(sync_delete_remote_resource(sn, local, &sync_delete)) {