260 |
260 |
261 static int res_matches_tags(DavResource *res, SyncTagFilter *tagfilter) { |
261 static int res_matches_tags(DavResource *res, SyncTagFilter *tagfilter) { |
262 if(!tagfilter || tagfilter->mode == DAV_SYNC_TAGFILTER_OFF) { |
262 if(!tagfilter || tagfilter->mode == DAV_SYNC_TAGFILTER_OFF) { |
263 return 1; |
263 return 1; |
264 } |
264 } |
265 int scope = res->iscollection ? |
265 // NOTE: currently not implementable |
266 DAV_SYNC_TAGFILTER_SCOPE_COLLECTION |
266 //int scope = res->iscollection ? |
267 : DAV_SYNC_TAGFILTER_SCOPE_RESOURCE; |
267 // DAV_SYNC_TAGFILTER_SCOPE_COLLECTION |
268 if(tagfilter->scope & scope != scope) { |
268 // : DAV_SYNC_TAGFILTER_SCOPE_RESOURCE; |
|
269 //if((tagfilter->scope & scope) != scope) { |
|
270 // return 1; |
|
271 //} |
|
272 if(res->iscollection) { |
269 return 1; |
273 return 1; |
270 } |
274 } |
271 |
275 |
272 DavXmlNode *tagsprop = dav_get_property_ns(res, DAV_NS, "tags"); |
276 DavXmlNode *tagsprop = dav_get_property_ns(res, DAV_NS, "tags"); |
273 UcxList *res_tags = parse_dav_xml_taglist(tagsprop); |
277 UcxList *res_tags = parse_dav_xml_taglist(tagsprop); |
286 SyncTagFilter *tagfilter) |
290 SyncTagFilter *tagfilter) |
287 { |
291 { |
288 if(!tagfilter || tagfilter->mode == DAV_SYNC_TAGFILTER_OFF) { |
292 if(!tagfilter || tagfilter->mode == DAV_SYNC_TAGFILTER_OFF) { |
289 return 1; |
293 return 1; |
290 } |
294 } |
291 int scope = res->isdirectory ? |
295 //int scope = res->isdirectory ? |
292 DAV_SYNC_TAGFILTER_SCOPE_COLLECTION |
296 // DAV_SYNC_TAGFILTER_SCOPE_COLLECTION |
293 : DAV_SYNC_TAGFILTER_SCOPE_RESOURCE; |
297 // : DAV_SYNC_TAGFILTER_SCOPE_RESOURCE; |
294 if(tagfilter->scope & scope != scope) { |
298 //if((tagfilter->scope & scope) != scope) { |
|
299 // return 1; |
|
300 //} |
|
301 if(res->isdirectory) { |
295 return 1; |
302 return 1; |
296 } |
303 } |
297 |
304 |
298 DavBool changed = 0; |
305 DavBool changed = 0; |
299 UcxList *res_tags = sync_get_file_tags(dir, res, &changed); |
306 UcxList *res_tags = sync_get_file_tags(dir, res, &changed); |
480 while(stack) { |
487 while(stack) { |
481 DavResource *res = stack->data; |
488 DavResource *res = stack->data; |
482 stack = ucx_list_remove(stack, stack); |
489 stack = ucx_list_remove(stack, stack); |
483 |
490 |
484 while(res) { |
491 while(res) { |
485 if ( res_matches_filter(dir, res->path) |
492 DavBool res_filtered = FALSE; |
486 || !res_matches_tags(res, dir->tagfilter)) |
493 if (res_matches_filter(dir, res->path)) { |
487 { |
494 res_filtered = TRUE; |
|
495 } else { |
|
496 UCX_FOREACH(elm, dir->tagfilter) { |
|
497 SyncTagFilter *tf = elm->data; |
|
498 if(!res_matches_tags(res, tf)) { |
|
499 res_filtered = TRUE; |
|
500 break; |
|
501 } |
|
502 } |
|
503 } |
|
504 if(res_filtered) { |
488 // don't delete files filtered by config |
505 // don't delete files filtered by config |
489 localres_keep(db, res->path); |
506 localres_keep(db, res->path); |
490 res = res->next; |
507 res = res->next; |
491 continue; |
508 continue; |
492 } |
509 } |
1024 int ret = 0; |
1041 int ret = 0; |
1025 UCX_FOREACH(elm, resources) { |
1042 UCX_FOREACH(elm, resources) { |
1026 LocalResource *local_res = elm->data; |
1043 LocalResource *local_res = elm->data; |
1027 int error = 0; |
1044 int error = 0; |
1028 |
1045 |
1029 if ( res_matches_filter(dir, local_res->path+1) |
1046 DavBool res_filtered = FALSE; |
1030 || !localres_matches_tags(dir, local_res, dir->tagfilter)) |
1047 if(res_matches_filter(dir, local_res->path+1)) { |
1031 { |
1048 res_filtered = TRUE; |
|
1049 } else { |
|
1050 UCX_FOREACH(elm, dir->tagfilter) { |
|
1051 SyncTagFilter *tf = elm->data; |
|
1052 if(!localres_matches_tags(dir, local_res, tf)) { |
|
1053 res_filtered = TRUE; |
|
1054 break; |
|
1055 } |
|
1056 } |
|
1057 } |
|
1058 if (res_filtered) { |
1032 local_res->keep = TRUE; |
1059 local_res->keep = TRUE; |
1033 } else if (!localres_matches_tags(dir, local_res, tagfilter)) { |
1060 } else if (!localres_matches_tags(dir, local_res, tagfilter)) { |
1034 if(!remove_file) { |
1061 if(!remove_file) { |
1035 local_res->keep = TRUE; |
1062 local_res->keep = TRUE; |
1036 } |
1063 } |
1135 // delete all removed files |
1162 // delete all removed files |
1136 if(ret == 0 && !archive) { |
1163 if(ret == 0 && !archive) { |
1137 UcxMapIterator i = ucx_map_iterator(db->resources); |
1164 UcxMapIterator i = ucx_map_iterator(db->resources); |
1138 LocalResource *local; |
1165 LocalResource *local; |
1139 UCX_MAP_FOREACH(key, local, i) { |
1166 UCX_MAP_FOREACH(key, local, i) { |
1140 if (!local->keep) { |
1167 if (!local->keep && !res_matches_filter(dir, local->path+1)) { |
1141 if(sync_shutdown) { |
1168 if(sync_shutdown) { |
1142 ucx_map_cstr_put(lclres, local->path, local_resource_copy(local)); |
1169 ucx_map_cstr_put(lclres, local->path, local_resource_copy(local)); |
1143 } else if(sync_delete_remote_resource(sn, local, &sync_delete)) { |
1170 } else if(sync_delete_remote_resource(sn, local, &sync_delete)) { |
1144 ucx_map_cstr_put(lclres, local->path, local_resource_copy(local)); |
1171 ucx_map_cstr_put(lclres, local->path, local_resource_copy(local)); |
1145 if(sn->error != DAV_NOT_FOUND) { |
1172 if(sn->error != DAV_NOT_FOUND) { |