copy/move with lock tokens works now

Wed, 23 Mar 2016 19:03:48 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 23 Mar 2016 19:03:48 +0100
changeset 236
6b4ce32d0c4e
parent 235
0468df02e18f
child 237
fd9135bc7580

copy/move with lock tokens works now

dav/main.c file | annotate | diff | comparison | revisions
dav/version.h file | annotate | diff | comparison | revisions
libidav/methods.c file | annotate | diff | comparison | revisions
libidav/methods.h file | annotate | diff | comparison | revisions
libidav/resource.c file | annotate | diff | comparison | revisions
--- a/dav/main.c	Wed Mar 23 13:46:39 2016 +0100
+++ b/dav/main.c	Wed Mar 23 19:03:48 2016 +0100
@@ -979,9 +979,7 @@
     if(set_session_config(sn, a)) {
         return -1;
     }
-    
-    // TODO: add lock support (do_copy_move_request doesn't support locks yet)
-    // set_session_lock(sn, a);
+    set_session_lock(sn, a);
     
     DavBool override = cmd_getoption(a, "override") ? true : false;
     
--- a/dav/version.h	Wed Mar 23 13:46:39 2016 +0100
+++ b/dav/version.h	Wed Mar 23 19:03:48 2016 +0100
@@ -29,7 +29,7 @@
 #ifndef VERSION_H
 #define VERSION_H
 
-#define DAV_VERSION "0.9.9 RC1"
+#define DAV_VERSION "1.0.0 RC2"
 
 #endif /* VERSION_H */
 
--- a/libidav/methods.c	Wed Mar 23 13:46:39 2016 +0100
+++ b/libidav/methods.c	Wed Mar 23 19:03:48 2016 +0100
@@ -1038,7 +1038,7 @@
 }
 
 
-CURLcode do_copy_move_request(CURL *handle, char *dest, _Bool copy, _Bool override) { 
+CURLcode do_copy_move_request(CURL *handle, char *dest, char *lock, DavBool copy, DavBool override) { 
     if(copy) {
         curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "COPY");
     } else {
@@ -1051,6 +1051,13 @@
     curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL);
     
     struct curl_slist *headers = NULL;
+    if(lock) {
+        char *url = NULL;
+        curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url);
+        char *ltheader = ucx_sprintf("If: <%s> (<%s>)", url, lock).ptr;
+        headers = curl_slist_append(headers, ltheader);
+        free(ltheader);
+    }
     //sstr_t deststr = ucx_sprintf("Destination: %s", dest);
     sstr_t deststr = sstrcat(2, S("Destination: "), sstr(dest));
     headers = curl_slist_append(headers, deststr.ptr);
--- a/libidav/methods.h	Wed Mar 23 13:46:39 2016 +0100
+++ b/libidav/methods.h	Wed Mar 23 19:03:48 2016 +0100
@@ -111,7 +111,7 @@
 
 CURLcode do_head_request(CURL *handle);
 
-CURLcode do_copy_move_request(CURL *handle, char *dest, _Bool copy, _Bool override);
+CURLcode do_copy_move_request(CURL *handle, char *dest, char *lock, DavBool copy, DavBool override);
 
 UcxBuffer* create_lock_request();
 int parse_lock_response(DavSession *sn, UcxBuffer *response, LockDiscovery *lock);
--- a/libidav/resource.c	Wed Mar 23 13:46:39 2016 +0100
+++ b/libidav/resource.c	Wed Mar 23 19:03:48 2016 +0100
@@ -905,7 +905,10 @@
     CURL *handle = sn->handle;
     util_set_url(sn, dav_resource_get_href(res));
     
-    CURLcode ret = do_copy_move_request(handle, desturl, copy, override);
+    DavLock *lock = dav_get_lock(sn, res->path);
+    char *locktoken = lock ? lock->token : NULL;
+    
+    CURLcode ret = do_copy_move_request(handle, desturl, locktoken, copy, override);
     
     long status = 0;
     curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status);

mercurial