Wed, 07 Feb 2024 17:11:55 +0100
add support for progress callbacks in dav_store()
libidav/resource.c | file | annotate | diff | comparison | revisions |
--- a/libidav/resource.c Tue Feb 06 13:29:31 2024 +0100 +++ b/libidav/resource.c Wed Feb 07 17:11:55 2024 +0100 @@ -40,7 +40,7 @@ #include <cx/utils.h> #include <cx/hash_map.h> #include <cx/printf.h> -#include <cx/basic_mempool.h> +#include <cx/mempool.h> #include <cx/array_list.h> #include "resource.h" @@ -787,7 +787,7 @@ } int dav_load_prop(DavResource *res, DavPropName *properties, size_t numprop) { - CxMempool *mp = cxBasicMempoolCreate(64); + CxMempool *mp = cxMempoolCreate(64, NULL); const CxAllocator *a = mp->allocator; CxList *proplist = cxArrayListCreate(a, NULL, sizeof(DavProperty), numprop); @@ -856,6 +856,10 @@ // store content if(data->content) { + curl_easy_setopt(sn->handle, CURLOPT_XFERINFOFUNCTION, dav_session_put_progress); + curl_easy_setopt(sn->handle, CURLOPT_XFERINFODATA, res); + curl_easy_setopt(sn->handle, CURLOPT_NOPROGRESS, 0L); + int encryption = DAV_ENCRYPT_CONTENT(sn) && sn->key; CURLcode ret; if(encryption) { @@ -900,6 +904,8 @@ // TODO: store the properties later if(resource_add_crypto_info(sn, res->href, res->name, enc_hash)) { free(enc_hash); + curl_easy_setopt(sn->handle, CURLOPT_XFERINFOFUNCTION, NULL); + curl_easy_setopt(sn->handle, CURLOPT_NOPROGRESS, 1L); return 1; } resource_add_string_property(res, DAV_NS, "crypto-hash", enc_hash); @@ -948,6 +954,9 @@ data->seek, data->length); } + + curl_easy_setopt(sn->handle, CURLOPT_XFERINFOFUNCTION, NULL); + curl_easy_setopt(sn->handle, CURLOPT_NOPROGRESS, 1L); long status = 0; curl_easy_getinfo(sn->handle, CURLINFO_RESPONSE_CODE, &status);