force mkcol for every directory in the dav put command

Sat, 25 Mar 2023 17:23:09 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 25 Mar 2023 17:23:09 +0100
changeset 744
f0d7178043c1
parent 743
716f6bf04c30
child 745
aea83a43b09a

force mkcol for every directory in the dav put command

dav/main.c file | annotate | diff | comparison | revisions
--- a/dav/main.c	Sun Mar 19 15:12:42 2023 +0100
+++ b/dav/main.c	Sat Mar 25 17:23:09 2023 +0100
@@ -1235,6 +1235,17 @@
         
         if(!root) {
             printf("mkcol: %s\n", file);
+            DavResource *res = dav_resource_new(sn, path);
+            res->iscollection = TRUE;
+            if(!dav_exists(res)) {
+                if(dav_create(res)) {
+                    fprintf(stderr, "Cannot create collection %s\n", path);
+                    print_resource_error(sn, res->path);
+                    dav_resource_free(res);
+                    return 1;
+                }
+            }
+            dav_resource_free(res);
         }
         
         SYS_DIR dir = sys_opendir(file);
@@ -1268,20 +1279,6 @@
             }
         }
         sys_closedir(dir);
-        
-        if(nument == 0) {
-            // create empty directory
-            DavResource *res = dav_resource_new(sn, path);
-            res->iscollection = TRUE;
-            if(!dav_exists(res)) {
-                if(dav_create(res)) {
-                    fprintf(stderr, "Cannot create collection %s\n", path);
-                    print_resource_error(sn, res->path);
-                    ret = 1;
-                }
-            }
-            dav_resource_free(res);
-        }
     } else if(S_ISREG(s.st_mode)) {
         if(printfile) {
             printf("put: %s\n", file);

mercurial