dav/sync.c

changeset 417
f340460a8b5d
parent 415
6e1861e8262c
child 444
761dc4867208
child 453
68a786fa4695
--- 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)) {

mercurial