fixed locking in dav-sync push

Sun, 20 Mar 2016 16:13:41 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 20 Mar 2016 16:13:41 +0100
changeset 227
bf485439222a
parent 226
acc997e0d0f9
child 228
c0175372c35d

fixed locking in dav-sync push

dav/sync.c file | annotate | diff | comparison | revisions
libidav/methods.c file | annotate | diff | comparison | revisions
libidav/resource.c file | annotate | diff | comparison | revisions
--- a/dav/sync.c	Sun Mar 20 15:28:08 2016 +0100
+++ b/dav/sync.c	Sun Mar 20 16:13:41 2016 +0100
@@ -780,6 +780,7 @@
                         print_resource_error(sn, res->path);
                         ret = -1;
                         sync_error++;
+                        error = 1;
                     }
                 } else {
                     if(cdt && remote_resource_is_changed(sn, dir, db, local_res)) {
@@ -793,7 +794,6 @@
                         sync_error++;
                         print_resource_error(sn, res->path);
                         ret = -1;
-                        sync_error++;
                         error = 1;
                     }
                 }
@@ -1102,7 +1102,7 @@
         (*counter)++;
         
         // check contentlength and get new etag
-        DavResource *up_res = dav_get(res->session, res->path, "D:getetag");
+        DavResource *up_res = dav_get(res->session, res->path, "D:getetag,idav:status");
         
         if(up_res) {
             // the new content length must be equal or greater than the file size
@@ -1129,9 +1129,12 @@
                 } else {
                     local->etag = NULL;
                 }
-                dav_resource_free(up_res);
                 
-                sync_remove_status(res);
+                if(dav_get_property(up_res, "idav:status")) {
+                    sync_remove_status(up_res);
+                }
+                
+                dav_resource_free(up_res);
             }
         }
     } else {
--- a/libidav/methods.c	Sun Mar 20 15:28:08 2016 +0100
+++ b/libidav/methods.c	Sun Mar 20 16:13:41 2016 +0100
@@ -901,6 +901,7 @@
 /* ----------------------------- PUT ----------------------------- */
 
 static size_t dummy_write(void *buf, size_t s, size_t n, void *data) {
+    //fwrite(buf, s, n, stdout);
     return s*n;
 }
 
@@ -991,7 +992,7 @@
         free(url);
         headers = curl_slist_append(headers, ltheader);
         free(ltheader);
-        curl_easy_setopt(handle, CURLOPT_HTTPHEADER, NULL);
+        curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
     } else {
         curl_easy_setopt(handle, CURLOPT_HTTPHEADER, NULL);
     }
--- a/libidav/resource.c	Sun Mar 20 15:28:08 2016 +0100
+++ b/libidav/resource.c	Sun Mar 20 16:13:41 2016 +0100
@@ -149,7 +149,6 @@
         dav_session_free(sn, p->ns);
         
         dav_session_free(sn, p->name);
-        dav_session_free(sn, p->value);
         dav_session_free(sn, p);
     }
     
@@ -583,7 +582,7 @@
             ret = do_put_request(
                     sn->handle,
                     locktoken,
-                    FALSE,
+                    TRUE,
                     enc,
                     (dav_read_func)aes_read,
                     0);
@@ -610,7 +609,7 @@
             ret = do_put_request(
                     sn->handle,
                     locktoken,
-                    FALSE,
+                    TRUE,
                     data->content,
                     data->read,
                     data->length);

mercurial