Sat, 28 Mar 2020 16:37:40 +0100
reimplement dav_exists by using dav_load_prop
libidav/resource.c | file | annotate | diff | comparison | revisions |
--- a/libidav/resource.c Sat Mar 28 16:28:52 2020 +0100 +++ b/libidav/resource.c Sat Mar 28 16:37:40 2020 +0100 @@ -1267,21 +1267,11 @@ } int dav_exists(DavResource *res) { - // TODO: reimplement with PROPFIND - - DavSession *sn = res->session; - CURL *handle = sn->handle; - util_set_url(sn, dav_resource_get_href(res)); - - CURLcode ret = do_head_request(sn); - long status = 0; - curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); - if(ret == CURLE_OK && (status >= 200 && status < 300)) { + if(!dav_load_prop(res, NULL, 0)) { res->exists = 1; return 1; } else { - dav_session_set_error(sn, ret, status); - if(status == 404) { + if(res->session->error == DAV_NOT_FOUND) { res->exists = 0; } return 0;