fix sync_store_metadata

Sat, 26 Oct 2019 14:55:53 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 26 Oct 2019 14:55:53 +0200
changeset 675
a8117c4feaad
parent 674
92bf06a65d08
child 676
fb466ba2edc5

fix sync_store_metadata

dav/sync.c file | annotate | diff | comparison | revisions
test/bin-test/test-dav-sync-metadata3.sh file | annotate | diff | comparison | revisions
test/bin-test/test-dav-sync.sh file | annotate | diff | comparison | revisions
--- a/dav/sync.c	Sat Oct 26 12:40:35 2019 +0200
+++ b/dav/sync.c	Sat Oct 26 14:55:53 2019 +0200
@@ -845,6 +845,7 @@
         }
     }
     
+    // update metadata
     UCX_FOREACH(elm, res_metadata) {
         DavResource *res = elm->data;
         if(sync_shutdown) {
@@ -1319,6 +1320,8 @@
     
     LocalResource *local = NULL;
     if(copy) {
+        // TODO: maybe we should not copy the whole resource
+        // with all metadata hashes
         local = local_resource_copy(content, res->path);
     } else {
         // reuse previous LocalResource (content)
@@ -3362,6 +3365,8 @@
     }
     
     if(!store_tags) {
+        nullfree(local->remote_tags_hash);
+        local->remote_tags_hash = remote_hash;
         return 0;
     }
     
--- a/test/bin-test/test-dav-sync-metadata3.sh	Sat Oct 26 12:40:35 2019 +0200
+++ b/test/bin-test/test-dav-sync-metadata3.sh	Sat Oct 26 14:55:53 2019 +0200
@@ -207,3 +207,35 @@
 	exit 2
 fi
 
+
+# ----------------------------------------------------------------------------
+# test 3: push again
+# expected result: 0 files pushed/updated
+
+dav_sync_push test4a "test 3: push failed"
+check_tmpout "0 files pushed" "test 3: wrong push counter"
+check_tmpout "0 conflicts" "test 3: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 3: wrong error counter (push)"
+
+LN=`cat tmp-sync/out.txt | wc -l 2> /dev/null`
+if [ $LN -ne 1 ]; then
+	echo "test 3: wrong line count"
+	exit 2
+fi
+
+
+# ----------------------------------------------------------------------------
+# test 4: pull test4b again
+# expected result: 0 files pushed/updated
+
+dav_sync_pull test4b "test 4: pull failed"
+check_tmpout "0 files pulled" "test 4: wrong pull counter"
+check_tmpout "0 conflicts" "test 4: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 4: wrong error counter (pull)"
+
+LN=`cat tmp-sync/out.txt | wc -l 2> /dev/null`
+if [ $LN -ne 1 ]; then
+	echo "test 4: wrong line count"
+	exit 2
+fi
+
--- a/test/bin-test/test-dav-sync.sh	Sat Oct 26 12:40:35 2019 +0200
+++ b/test/bin-test/test-dav-sync.sh	Sat Oct 26 14:55:53 2019 +0200
@@ -94,15 +94,15 @@
 #
 do_test "dav-sync push (1)" test-dav-sync-push1.sh
 do_test "dav-sync pull (1)" test-dav-sync-pull1.sh
-#do_test "dav-sync pull conflict (1)" test-dav-sync-pull-conflict.sh
-#do_test "dav-sync push conflict (1)" test-dav-sync-push-conflict.sh
-#do_test "dav-sync hashing (1)" test-dav-sync-hashing1.sh
-#do_test "dav-sync hashing (2)" test-dav-sync-hashing1.sh
-#do_test "dav-sync hash strategy" test-dav-sync-hash-strategy.sh
-#do_test "dav-sync hash conflict resolution" test-dav-sync-hash-conflictres.sh
-#do_test "dav-sync hashing change cfg" test-dav-sync-hashing-cfgchange.sh
-#do_test "dav-sync metadata (1)" test-dav-sync-metadata1.sh
-#do_test "dav-sync metadata (2)" test-dav-sync-metadata2.sh
+do_test "dav-sync pull conflict (1)" test-dav-sync-pull-conflict.sh
+do_test "dav-sync push conflict (1)" test-dav-sync-push-conflict.sh
+do_test "dav-sync hashing (1)" test-dav-sync-hashing1.sh
+do_test "dav-sync hashing (2)" test-dav-sync-hashing1.sh
+do_test "dav-sync hash strategy" test-dav-sync-hash-strategy.sh
+do_test "dav-sync hash conflict resolution" test-dav-sync-hash-conflictres.sh
+do_test "dav-sync hashing change cfg" test-dav-sync-hashing-cfgchange.sh
+do_test "dav-sync metadata (1)" test-dav-sync-metadata1.sh
+do_test "dav-sync metadata (2)" test-dav-sync-metadata2.sh
 do_test "dav-sync metadata (3)" test-dav-sync-metadata3.sh
 
 # cleanup

mercurial