Thu, 03 Aug 2017 14:32:36 +0200
fixes unnecessary mkcol in dav-sync
dav/sync.c | file | annotate | diff | comparison | revisions |
--- 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); } }