Sat, 19 Oct 2019 11:15:04 +0200
fix mtime sync bug
dav/sync.c | file | annotate | diff | comparison | revisions | |
test/bin-test/test-dav-sync-metadata1.sh | file | annotate | diff | comparison | revisions |
--- a/dav/sync.c Sat Oct 19 10:47:46 2019 +0200 +++ b/dav/sync.c Sat Oct 19 11:15:04 2019 +0200 @@ -2858,6 +2858,13 @@ res->metadata_updated = res->tags_updated; } + // check if mtime has changed + if((dir->metadata & FINFO_MTIME) == FINFO_MTIME) { + if(db_res->last_modified != res->last_modified) { + res->finfo_updated = 1; + res->metadata_updated = 1; + } + } // check if mode has changed if((dir->metadata & FINFO_MODE) == FINFO_MODE) { if(db_res->mode != res->mode) {
--- a/test/bin-test/test-dav-sync-metadata1.sh Sat Oct 19 10:47:46 2019 +0200 +++ b/test/bin-test/test-dav-sync-metadata1.sh Sat Oct 19 11:15:04 2019 +0200 @@ -90,7 +90,7 @@ mkdir tmp-sync/test4b # ---------------------------------------------------------------------------- -# 1. test: sync executable file and check if it can be executed +# test 1: sync executable file and check if it can be executed # expected result: exec works echo "#!/bin/sh" > tmp-sync/test4a/script.sh @@ -127,3 +127,63 @@ fi fi +# ---------------------------------------------------------------------------- +# test 2: set mtime to specific date and sync the file +# expected result: mtime the same on both sides + +mkdir tmp-sync/test4a/dir1 + +cp synctest/file1 tmp-sync/test4a/ +cp synctest/file2 tmp-sync/test4a/dir1/ + +touch -t 01011200 tmp-sync/test4a/file1 +touch -t 02021200 tmp-sync/test4a/dir1/file2 + +dav_sync_push test4a "test 2: push failed" +check_tmpout "2 files pushed" "test 2: wrong push counter" +check_tmpout "0 conflicts" "test 2: wrong conflict counter (push)" +check_tmpout "0 errors" "test 2: wrong error counter (push)" + +dav_sync_pull test4b "test 2: pull failed" +check_tmpout "2 files pulled" "test 2: wrong pull counter" +check_tmpout "0 conflicts" "test 2: wrong conflict counter (pull)" +check_tmpout "0 errors" "test 2: wrong error counter (pull)" + +MTIMEA1=`stat -c %Y tmp-sync/test4a/file1` +MTIMEB1=`stat -c %Y tmp-sync/test4b/file1` + +MTIMEA2=`stat -c %Y tmp-sync/test4a/dir1/file2` +MTIMEB2=`stat -c %Y tmp-sync/test4b/dir1/file2` + +if [ $MTIMEA1 != $MTIMEB1 ]; then + echo "file1: mtime not synced" + exit 2 +fi +if [ $MTIMEA2 != $MTIMEB2 ]; then + echo "file2: mtime not synced" + exit 2 +fi + +# ---------------------------------------------------------------------------- +# test 3: modify file1 and push/pull +# expected result: file content synced, mtime also synced + +echo "test3-mod1" >> tmp-sync/test4a/file1 + +dav_sync_push test4a "test 3: push failed" +check_tmpout "1 file 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)" + +dav_sync_pull test4b "test 3: pull failed" +check_tmpout "1 file pulled" "test 3: wrong pull counter" +check_tmpout "0 conflicts" "test 3: wrong conflict counter (pull)" +check_tmpout "0 errors" "test 3: wrong error counter (pull)" + +MTIMEA1=`stat -c %Y tmp-sync/test4a/file1` +MTIMEB1=`stat -c %Y tmp-sync/test4b/file1` + +if [ $MTIMEA1 != $MTIMEB1 ]; then + echo "file1: mtime not synced" + exit 2 +fi