src/server/webdav/webdav.c

branch
webdav
changeset 246
155bdef7fe7e
parent 245
a193c42fc809
child 247
1df803e06076
--- a/src/server/webdav/webdav.c	Sun Feb 02 17:42:05 2020 +0100
+++ b/src/server/webdav/webdav.c	Sun May 31 13:08:42 2020 +0200
@@ -46,6 +46,7 @@
 #include "../daemon/session.h"
 #include "../daemon/http.h"
 #include "../daemon/protocol.h"
+#include "../daemon/vfs.h"
 
 static UcxMap *method_handler_map;
 
@@ -460,13 +461,9 @@
     return REQ_ABORTED;
 }
 
-static int webdav_delete_collection(
-        Session *sn,
-        Request *rq,
-        VFSContext *vfs,
-        const char *path)
+static int webdav_delete_collection(WebdavVFSOperation *op)
 {
-    
+    // TODO
 }
 
 int webdav_delete(pblock *pb, Session *sn, Request *rq) { 
@@ -475,7 +472,19 @@
         return REQ_ABORTED;
     }
     
-    int ret = webdav_vfs_op_do(op, WEBDAV_VFS_MKDIR);
+    // stat to find out if the resource is a collection
+    struct stat s;
+    if(vfs_stat(op->vfs, op->path, &s)) {
+        sys_set_error_status(op->vfs);
+        return REQ_ABORTED;
+    }
+    
+    int ret;
+    if(S_ISDIR(s.st_mode)) {
+        ret = webdav_delete_collection(op);
+    } else {
+        ret = webdav_vfs_op_do(op, WEBDAV_VFS_DELETE);
+    }
     
     return ret;
 }

mercurial