# HG changeset patch # User Olaf Wintermann # Date 1660834103 -7200 # Node ID 0344108db2557b1b2d24e0f0faea513277135084 # Parent c011bc2b314316ed1713507333aabc4e4f3b0675 make original proppatch property list available to all backends diff -r c011bc2b3143 -r 0344108db255 src/server/plugins/postgresql/webdav.c --- a/src/server/plugins/postgresql/webdav.c Mon Aug 15 15:45:55 2022 +0200 +++ b/src/server/plugins/postgresql/webdav.c Thu Aug 18 16:48:23 2022 +0200 @@ -578,7 +578,7 @@ pool_handle_t *pool = rq->sn->pool; PGresult *result = pg->result; WebdavVFSProperties vfsprops = pg->vfsproperties; - + WSBool vfsprops_set = 0; // are live properties added to the response? WSBool extprops_set = 0; // are extended properties added to the response? int64_t current_resource_id = pg->resource_id; @@ -633,6 +633,7 @@ // new resource resource = response->addresource(response, newres_href); vfsprops_set = FALSE; + extprops_set = FALSE; current_resource_id = resource_id; } @@ -1259,7 +1260,9 @@ if(PQresultStatus(result) == PGRES_COMMAND_OK) { // command ok, check if any row was updated char *nrows_affected = PQcmdTuples(result); - if(nrows_affected[0] == '0') { + if(nrows_affected[0] == '1') { + ret = 0; + } else if(nrows_affected[0] == '0') { // no rows affected, that means we have to insert a new row // in the extension table for this resource @@ -1267,7 +1270,6 @@ ret = ext_row_insert(request, ext, table); } - } else { log_ereport(LOG_FAILURE, "pg: extension row update failed: %s", PQresultErrorMessage(result)); } @@ -1306,6 +1308,7 @@ char *path = pblock_findkeyval(pb_key_path, request->rq->vars); PgProppatch proppatch; + proppatch.extensions_used = FALSE; if(pgdav->repository->ntables == 0) { proppatch.ext = NULL; proppatch.numext = 0; @@ -1348,7 +1351,7 @@ } proppatch.resource_id = resource_id; - + // because proppatch must be atomic and we have multiple sql // queries and other backends that do stuff that could fail // we need the possibility to reverse all changes @@ -1361,7 +1364,9 @@ } char resource_id_str[32]; - snprintf(resource_id_str, 32, "%" PRId64, resource_id); + snprintf(resource_id_str, 32, "%" PRId64, resource_id); + // store the resource_id in rq->vars, because it could be useful later + pblock_nvinsert("resource_id", resource_id_str, request->rq->vars); int ret = 0; PgProppatchOpResult set_res = pg_proppatch_op( diff -r c011bc2b3143 -r 0344108db255 src/server/public/webdav.h --- a/src/server/public/webdav.h Mon Aug 15 15:45:55 2022 +0200 +++ b/src/server/public/webdav.h Thu Aug 18 16:48:23 2022 +0200 @@ -307,7 +307,7 @@ * Finishes a propfind request. */ int (*propfind_finish)(WebdavPropfindRequest *); - + /* * int proppatch_do( * WebdavProppatchRequest *request, diff -r c011bc2b3143 -r 0344108db255 src/server/webdav/operation.c --- a/src/server/webdav/operation.c Mon Aug 15 15:45:55 2022 +0200 +++ b/src/server/webdav/operation.c Thu Aug 18 16:48:23 2022 +0200 @@ -325,10 +325,10 @@ sizeof(WebdavProppatchRequest)); memcpy(req, orig_request, sizeof(WebdavProppatchRequest)); req->dav = dav; - req->set = set; - req->setcount = set_count; - req->remove = remove; - req->removecount = remove_count; + req->set = orig_request->set; + req->setcount = orig_request->setcount; + req->remove = orig_request->remove; + req->removecount = orig_request->removecount; req->userdata = NULL; // check if we need to open the file because the backend wants it