Re: problems creating subdirs with fetch+synch

Joe Orton <[email protected]> Mon, 12 Dec 2005 21:14:09 +0000
Newsgroups gmane.comp.web.sitecopy
Message-ID <[email protected]>
On Mon, Dec 12, 2005 at 08:58:40AM +0000, Joe Orton wrote:
> On Mon, Dec 12, 2005 at 11:24:15AM +1100, Matthew Hannigan wrote:
> > debug=ftp?  Is that appropriate for non-ftp too? (my case is webdav->plain ol' fs)
> 
> Ah ha.  Well that's the critical information from the rcfile entry :) I 
> can reproduce this with a --fetch over DAV too, I'll have a look at it.

Here's the patch, let me know if you still have problems with this 
applied:

Index: src/davdriver.c
===================================================================
--- src/davdriver.c	(revision 739)
+++ src/davdriver.c	(working copy)
@@ -58,6 +58,7 @@
 
 struct fetch_context {
     struct proto_file **files;
+    struct proto_file *tail;
     const char *root;
 };
 
@@ -92,14 +93,6 @@
     { NULL }
 };
 
-static inline int get_depth(const char *href) {
-    const char *pnt;
-    int count = 0;
-    for (pnt=href; *pnt != '\0'; pnt++) /* oneliner */
-	if (*pnt == '/') count++;
-    return count;
-}
-
 /* Set session error string to 'msg: strerror(errnum)'. */
 static void syserr(ne_session *sess, const char *msg, int errnum)
 {
@@ -537,21 +530,15 @@
 
 /* Insert the file in the list in the appropriate position (keeping it
  * sorted). */
-static void insert_file(struct proto_file **list, struct proto_file *file)
+static void insert_file(struct fetch_context *ctx, struct proto_file *file)
 {
-    struct proto_file *previous, *current;
-    previous = NULL;
-    current = *list;
-    while (current != NULL && current->depth < file->depth) {
-	previous = current;
-	current = current->next;
-    }
-    if (previous == NULL) {
-	*list = file;
+    if (ctx->tail) {
+        ctx->tail->next = file;
     } else {
-	previous->next = file;
+        (*ctx->files) = file;
     }
-    file->next = current;
+    ctx->tail = file;
+    file->next = NULL;
 }
 
 static void pfind_results(void *userdata, const char *href,
@@ -589,7 +576,7 @@
     if (!ne_path_childof(ctx->root, uhref)) {
 	/* URI not a child of the root collection...  ignore this
 	 * resource */
-	NE_DEBUG(NE_DBG_HTTP, "outside root collection!\n");
+	NE_DEBUG(NE_DBG_HTTP, "not child of root collection!\n");
 	return;
     }
    
@@ -617,7 +604,6 @@
 
     file = ne_calloc(sizeof(struct proto_file));
     file->filename = ne_strdup(uhref+strlen(ctx->root));
-    file->depth = get_depth(file->filename);
     
     if (iscoll) {
 	file->type = proto_dir;
@@ -639,8 +625,7 @@
     }
 
     /* Insert the file into the files list. */
-    insert_file(ctx->files, file);
-
+    insert_file(ctx, file);
 }
 
 static int start_element(void *userdata, int parent,
@@ -673,7 +658,7 @@
  * when we don't want it, since it forces a 404 propstat for each
  * non-collection resource if it is not defined.  */
 static int fetch_list(void *session, const char *dirname, int need_modtimes,
-		       struct proto_file **files) 
+                      struct proto_file **files) 
 {
     ne_session *sess = session;
     int ret;
@@ -683,6 +668,7 @@
 
     ctx.root = dirname;
     ctx.files = files;
+    ctx.tail = NULL;
     ph = ne_propfind_create(sess, edirname, NE_DEPTH_ONE);
 
     /* The complex props. */

_______________________________________________
sitecopy maillist  -  [email protected]
http://dav.lyra.org/mailman/listinfo/sitecopy