# HG changeset patch # User Olaf Wintermann # Date 1501763556 -7200 # Node ID b321a3be0a38fcc14ecbcbc4ad70058c39af54c7 # Parent 7b1ca53f38970cb8d2ac547efeaf6510a40abe85 fixes unnecessary mkcol in dav-sync diff -r 7b1ca53f3897 -r b321a3be0a38 dav/sync.c --- a/dav/sync.c Thu Aug 03 12:48:28 2017 +0200 +++ b/dav/sync.c Thu Aug 03 14:32:36 2017 +0200 @@ -302,6 +302,8 @@ UcxMap *svrres = ucx_map_new(db->resources->count); + UcxList *statls = NULL; + UcxList *stack = ucx_list_prepend(NULL, ls->children); while(stack) { DavResource *res = stack->data; @@ -332,6 +334,11 @@ ucx_map_cstr_put(svrres, res->path, local); ucx_map_cstr_remove(db->resources, res->path); + if(local->last_modified == 0) { + // stat this file later (directory) + statls = ucx_list_prepend(statls, local); + } + if(res->children) { stack = ucx_list_prepend(stack, res->children); } @@ -339,6 +346,18 @@ } } + // stat all files with unknown lastmodified date + UCX_FOREACH(elm, statls) { + LocalResource *l = elm->data; + char *local_path = util_concat_path(dir->path, l->path); + struct stat s; + if(!stat(local_path, &s)) { + l->last_modified = s.st_mtime; + } + free(local_path); + } + ucx_list_free(statls); + // delete every remotely removed resource UcxMapIterator i = ucx_map_iterator(db->resources); LocalResource *local; @@ -408,6 +427,7 @@ char *etag = dav_get_property(res, "D:getetag"); struct stat s; + memset(&s, 0, sizeof(struct stat)); if(local && !res->iscollection) { int exists = 1; if(stat(local_path, &s)) { @@ -465,7 +485,7 @@ // new local resource local = calloc(1, sizeof(LocalResource)); local->path = util_concat_path(res->path, "/"); - local->last_modified = s.st_mtime; + local->last_modified = 0; ucx_map_cstr_put(db->resources, local->path, local); } }