dav-sync bugfix: files that are not in the db but on the server should not be pushed

Sun, 01 Oct 2017 17:37:59 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 01 Oct 2017 17:37:59 +0200
changeset 318
7e0694423838
parent 317
7eea57f6d847
child 319
2433b5969d44

dav-sync bugfix: files that are not in the db but on the server should not be pushed

dav/main.c file | annotate | diff | comparison | revisions
dav/sync.c file | annotate | diff | comparison | revisions
--- a/dav/main.c	Sun Sep 24 14:31:42 2017 +0200
+++ b/dav/main.c	Sun Oct 01 17:37:59 2017 +0200
@@ -820,7 +820,7 @@
         if(!recursive) {
             fprintf(
                     stderr,
-                    "%s is a directory.\nUse the -R option to upload directories.",
+                    "%s is a directory.\nUse the -R option to upload directories.\n",
                     file);
             return 1;
         }
--- a/dav/sync.c	Sun Sep 24 14:31:42 2017 +0200
+++ b/dav/sync.c	Sun Oct 01 17:37:59 2017 +0200
@@ -1181,7 +1181,10 @@
     int ret = 0;
     if(remote) {
         char *etag = dav_get_property(remote, "D:getetag");
-        if(etag && res->etag) {
+        if(!res->etag) {
+            // the resource is on the server and the client has no etag
+            ret = 1;
+        } else if(etag) {
             sstr_t e = sstr(etag);
             if(sstrprefix(e, S("W/"))) {
                 e = sstrsubs(e, 2);
@@ -1189,6 +1192,9 @@
             if(strcmp(e.ptr, res->etag)) {
                 ret = 1;
             }
+        } else {
+            // something weird is happening, the server must support etags
+            fprintf(stderr, "Warning: resource %s has no etag\n", remote->href);
         }
         dav_resource_free(remote);
     }

mercurial