src/server/webdav/operation.c

branch
webdav
changeset 247
1df803e06076
parent 246
155bdef7fe7e
child 249
3b302093945c
--- a/src/server/webdav/operation.c	Sun May 31 13:08:42 2020 +0200
+++ b/src/server/webdav/operation.c	Sun May 31 16:58:23 2020 +0200
@@ -444,6 +444,22 @@
     return op;
 }
 
+WebdavVFSOperation webdav_vfs_sub_op(
+        WebdavVFSOperation *op,
+        char *path,
+        struct stat *s)
+{
+    WebdavVFSOperation sub;
+    sub.dav = op->dav;
+    sub.path = path;
+    sub.sn = op->sn;
+    sub.vfs = op->vfs;
+    sub.path = op->path;
+    sub.stat = s;
+    sub.stat_errno = 0;
+    return sub;
+}
+
 int webdav_op_iterate_children(
         VFSContext *vfs,
         int depth,
@@ -456,10 +472,10 @@
     pool_handle_t *pool = vfs->sn->pool;
     
     PathSearchElm *start_elm = pool_malloc(pool, sizeof(PathSearchElm));
-    start_elm->href = pool_strdup(pool, href);
-    start_elm->path = pool_strdup(pool, path);
-    start_elm->hreflen = strlen(href);
-    start_elm->pathlen = strlen(path);
+    start_elm->href = pool_strdup(pool, href ? href : "");
+    start_elm->path = pool_strdup(pool, path ? path : "");
+    start_elm->hreflen = href ? strlen(href) : 0;
+    start_elm->pathlen = path ? strlen(path) : 0;
     
     UcxList *stack = ucx_list_prepend_a(a, NULL, start_elm);
     UcxList *stack_end = stack;
@@ -724,20 +740,15 @@
 
 int webdav_vfs_unlink(WebdavVFSOperation *op) {
     // stat the file first, to check if the file is a directory
-    // deletion of simple files can be done just here,
-    // whereas deleting directories is more complicated
     if(webdav_vfs_stat(op)) {
         return 1; // error
     } else {
-        int r = 0;
         if(!S_ISDIR(op->stat->st_mode)) {
             return vfs_unlink(op->vfs, op->path);
+        } else {
+            return vfs_rmdir(op->vfs, op->path);
         }
     }
     
-    // delete directory:
-    
-    
-    
     return 0;
 }

mercurial