adjust pg plugin to new dav initialization webdav

Wed, 10 Aug 2022 21:01:54 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 10 Aug 2022 21:01:54 +0200
branch
webdav
changeset 370
d6d8c86c95c3
parent 369
e28ee9875a90
child 371
ea836c4f7341

adjust pg plugin to new dav initialization

src/server/plugins/postgresql/vfs.c file | annotate | diff | comparison | revisions
src/server/plugins/postgresql/webdav.c file | annotate | diff | comparison | revisions
--- a/src/server/plugins/postgresql/vfs.c	Wed Aug 10 20:56:24 2022 +0200
+++ b/src/server/plugins/postgresql/vfs.c	Wed Aug 10 21:01:54 2022 +0200
@@ -147,11 +147,18 @@
 }
 
 VFS* pg_vfs_create(Session *sn, Request *rq, pblock *pb, void *initData) {
-    // resourcepool is required
-    char *resource_pool = pblock_findval("resourcepool", pb);
-    if(!resource_pool) {
-        log_ereport(LOG_MISCONFIG, "pg_vfs_create: missing resourcepool parameter");
-        return NULL;
+    PgRepository *repo = initData;
+    
+    char *resource_pool;
+    if(repo) {
+        resource_pool = repo->resourcepool.ptr;
+    } else {
+        // resourcepool is required
+        resource_pool = pblock_findval("resourcepool", pb);
+        if(!resource_pool) {
+            log_ereport(LOG_MISCONFIG, "pg_vfs_create: missing resourcepool parameter");
+            return NULL;
+        }
     }
     
     // get the resource first (most likely to fail due to misconfig)
--- a/src/server/plugins/postgresql/webdav.c	Wed Aug 10 20:56:24 2022 +0200
+++ b/src/server/plugins/postgresql/webdav.c	Wed Aug 10 21:01:54 2022 +0200
@@ -275,11 +275,18 @@
 }
 
 WebdavBackend* pg_webdav_create(Session *sn, Request *rq, pblock *pb, void *initData) {
-    // resourcepool is required
-    char *resource_pool = pblock_findval("resourcepool", pb);
-    if(!resource_pool) {
-        log_ereport(LOG_MISCONFIG, "pg_webdav_create: missing resourcepool parameter");
-        return NULL;
+    PgRepository *repo = initData;
+    
+    char *resource_pool;
+    if(repo) {
+        resource_pool = repo->resourcepool.ptr;
+    } else {
+        // resourcepool is required
+        resource_pool = pblock_findval("resourcepool", pb);
+        if(!resource_pool) {
+            log_ereport(LOG_MISCONFIG, "pg_webdav_create: missing resourcepool parameter");
+            return NULL;
+        }
     }
     
     // get the resource first (should only fail in case of misconfig)

mercurial