dav/sync.c

changeset 73
41e88442ad4e
parent 72
aac29f2e8030
child 75
56962faf2b42
--- a/dav/sync.c	Tue Dec 30 13:24:03 2014 +0100
+++ b/dav/sync.c	Thu Jan 29 11:43:41 2015 +0100
@@ -133,6 +133,18 @@
     return 1;
 }
 
+static DavSession* create_session(DavContext *ctx, Repository *repo, char *url) {
+    DavSession *sn = dav_session_new_auth(
+            ctx,
+            url,
+            repo->user,
+            repo->password);
+    curl_easy_setopt(sn->handle, CURLOPT_SSLVERSION, repo->ssl_version);
+    sn->flags = get_repository_flags(repo);
+    sn->key = dav_context_get_key(ctx, repo->default_key);
+    return sn;
+}
+
 int cmd_pull(CmdArgs *a) {
     if(a->argc != 1) {
         fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few" : "many");
@@ -161,17 +173,10 @@
     if(dir->collection) {
         new_url = util_concat_path(repo->url, dir->collection);
     }
-    // TODO: session creator function
-    DavSession *sn = dav_session_new_auth(
-            ctx,
-            new_url ? new_url : repo->url,
-            repo->user,
-            repo->password);
+    DavSession *sn = create_session(ctx, repo, new_url ? new_url : repo->url);
     if(new_url) {
         free(new_url);
     }
-    sn->flags = get_repository_flags(repo);
-    sn->key = dav_context_get_key(ctx, repo->default_key);
     if (cmd_getoption(a, "verbose")) {
         curl_easy_setopt(sn->handle, CURLOPT_VERBOSE, 1L);
         curl_easy_setopt(sn->handle, CURLOPT_STDERR, stderr);
@@ -465,17 +470,10 @@
     if(dir->collection) {
         new_url = util_concat_path(repo->url, dir->collection);
     }
-    // TODO: session creator function
-    DavSession *sn = dav_session_new_auth(
-            ctx,
-            new_url ? new_url : repo->url,
-            repo->user,
-            repo->password);
+    DavSession *sn = create_session(ctx, repo, new_url ? new_url : repo->url);
     if(new_url) {
         free(new_url);
     }
-    sn->flags = get_repository_flags(repo);
-    sn->key = dav_context_get_key(ctx, repo->default_key);
     if (cmd_getoption(a, "verbose")) {
         curl_easy_setopt(sn->handle, CURLOPT_VERBOSE, 1L);
         curl_easy_setopt(sn->handle, CURLOPT_STDERR, stderr);

mercurial