dav/sync.c

changeset 639
928a77ebe0b9
parent 638
b3077bdb3d77
child 643
5b8643cf0a2f
--- a/dav/sync.c	Sat Sep 07 17:45:50 2019 +0200
+++ b/dav/sync.c	Sat Sep 07 19:25:51 2019 +0200
@@ -2081,7 +2081,8 @@
                     dir,
                     db,
                     origin_res,
-                    local->origin);
+                    local->origin,
+                    NULL);
             if(origin_changed) {
                 // upload with put
                 ls_modified = ucx_list_prepend(ls_modified, local);               
@@ -2127,8 +2128,13 @@
             ret = -1;
             sync_error++;
         } else {
-            int changed = remote_resource_is_changed(sn, dir, db, res, local_res);
-            if(cdt && changed) {
+            DavBool equal = FALSE;
+            int changed = remote_resource_is_changed(sn, dir, db, res, local_res, &equal);
+            if(equal) {
+                if(local_res->metadata_updated) {
+                    ls_update = ucx_list_prepend(ls_update, local_res);
+                }
+            } else if(cdt && changed) {
                 printf("conflict: %s\n", local_res->path);
                 local_res->last_modified = 0;
                 nullfree(local_res->etag);
@@ -2864,8 +2870,13 @@
         SyncDirectory *dir,
         SyncDatabase *db,
         DavResource *remote,
-        LocalResource *res)
+        LocalResource *res,
+        DavBool *equal)
 {
+    if(equal) {
+        *equal = FALSE;
+    }
+    
     DavPropName properties[] = {
         {"DAV:", "getetag"},
         {DAV_NS, "version-collection"},
@@ -2888,6 +2899,15 @@
     if(err == 0) {
         char *etag = dav_get_string_property(remote, "D:getetag");
         char *hash = sync_get_content_hash(remote);
+        
+        if(hash && res->hash && equal) {
+            // if requested, check if the local and remote are equal
+            if(!strcmp(hash, res->hash)) {
+                *equal = TRUE;
+                return 0;
+            }
+        }
+        
         if(hash && res->prev_hash) {
             if(strcmp(hash, res->prev_hash)) {
                 ret = 1;

mercurial