make original proppatch property list available to all backends webdav

Thu, 18 Aug 2022 16:48:23 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 18 Aug 2022 16:48:23 +0200
branch
webdav
changeset 378
0344108db255
parent 377
c011bc2b3143
child 379
4e2cb3adc0f2

make original proppatch property list available to all backends

src/server/plugins/postgresql/webdav.c file | annotate | diff | comparison | revisions
src/server/public/webdav.h file | annotate | diff | comparison | revisions
src/server/webdav/operation.c file | annotate | diff | comparison | revisions
--- 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(
--- 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,
--- 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

mercurial