fix default webdav backend initialization

Sat, 18 Mar 2023 11:34:48 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 18 Mar 2023 11:34:48 +0100
changeset 476
477cbeec7b0b
parent 475
d01ea909d906
child 477
39ebd50cfc12

fix default webdav backend initialization

src/server/webdav/webdav.c file | annotate | diff | comparison | revisions
--- a/src/server/webdav/webdav.c	Sat Mar 18 11:07:12 2023 +0100
+++ b/src/server/webdav/webdav.c	Sat Mar 18 11:34:48 2023 +0100
@@ -44,6 +44,8 @@
 #include "requestparser.h"
 #include "operation.h"
 
+#include "xattrbackend.h"
+
 #include "../util/pblock.h"
 #include "../util/util.h"
 #include "../daemon/session.h"
@@ -75,7 +77,18 @@
 
 #define WEBDAV_RESOURCE_TYPE_COLLECTION "<D:collection/>"
 
-static void init_default_backend(void) {
+
+static WebdavBackend* default_backend_create(Session *sn, Request *rq, pblock *pb, void *initData) {
+    WebdavBackend *dav = pool_malloc(sn->pool, sizeof(WebdavBackend));
+    if(!dav) {
+        return NULL;
+    }
+    
+    *dav = default_backend;
+    return dav;
+}
+
+static int init_default_backend(void) {
     memset(&default_backend, 0, sizeof(WebdavBackend));
     default_backend.propfind_init = default_propfind_init;
     default_backend.propfind_do = default_propfind_do;
@@ -86,8 +99,11 @@
     default_backend.opt_delete = NULL;
     default_backend.settings = WS_WEBDAV_PROPFIND_USE_VFS;
     default_backend.instance = NULL;
+    
+    return webdav_register_backend("default", NULL, default_backend_create);
 }
 
+
 int webdav_register_backend(const char *name, webdav_init_func webdavInit, webdav_create_func webdavCreate) {
     WebdavType *webdavType = malloc(sizeof(WebdavType));
     webdavType->init = webdavInit;
@@ -140,8 +156,13 @@
         return REQ_ABORTED;
     }
     
-    init_default_backend();
-    cxMapPut(webdav_type_map, cx_hash_key_str("default"), &default_backend);
+    if(init_default_backend()) {
+        return REQ_ABORTED;
+    }
+    
+    if(webdav_init_xattr_backend()) {
+        return REQ_ABORTED;
+    }
     
     cxMapPut(method_handler_map, cx_hash_key_str("OPTIONS"), webdav_options);
     cxMapPut(method_handler_map, cx_hash_key_str("PROPFIND"), webdav_propfind);

mercurial