Thu, 15 Aug 2019 20:25:21 +0200
fix url2repo not creating a string dup in case a repo doesn't exist
dav/main.c | file | annotate | diff | comparison | revisions |
--- a/dav/main.c Thu Aug 15 20:00:40 2019 +0200 +++ b/dav/main.c Thu Aug 15 20:25:21 2019 +0200 @@ -384,7 +384,7 @@ *path = strdup("/"); } else if (strchr(url, '/')) { repo->url = util_url_base(url); - *path = util_url_path(url); + *path = strdup(util_url_path(url)); } else { repo->url = strdup(url); *path = strdup("/"); @@ -1555,6 +1555,18 @@ return dav_create(res); } +static void print_cannoterr(DavSession *sn, const char *message) { + switch(sn->error) { + case DAV_UNSUPPORTED_PROTOCOL: + case DAV_COULDNT_RESOLVE_PROXY: + case DAV_COULDNT_RESOLVE_HOST: + case DAV_COULDNT_CONNECT: + case DAV_TIMEOUT: + case DAV_SSL_ERROR: break; + default: fprintf(stderr, "Cannot %s.\n", message); + } +} + static int cmd_operation_on_resources(CmdArgs* a, int(*operation)(DavResource*), const char* command, @@ -1589,7 +1601,7 @@ if(a->argc == 1) { if(operation(res)) { - fprintf(stderr, "Cannot %s.\n", message); + print_cannoterr(sn, message); print_resource_error(sn, res->path); goto cmd_oponres_exit; } @@ -1599,7 +1611,7 @@ assert(!!child); child->iscollection = 1; if(operation(child)) { - fprintf(stderr, "Cannot %s %s.\n", message, a->argv[i]); + print_cannoterr(sn, message); print_resource_error(sn, child->path); goto cmd_oponres_exit; }