Thu, 28 Mar 2019 14:18:54 +0100
fixes that pull downloads the history collection
dav/sync.c | file | annotate | diff | comparison | revisions | |
libidav/utils.c | file | annotate | diff | comparison | revisions | |
libidav/utils.h | file | annotate | diff | comparison | revisions |
--- a/dav/sync.c Thu Mar 28 11:54:27 2019 +0100 +++ b/dav/sync.c Thu Mar 28 14:18:54 2019 +0100 @@ -284,6 +284,13 @@ free(rpath.ptr); } + // versioning filter + if (dir->versioning) { + if(util_path_isrelated(dir->versioning->collection, res_path)) { + return 1; + } + } + // include/exclude filter UCX_FOREACH(inc, dir->include) { regex_t* pattern = (regex_t*) inc->data; @@ -517,7 +524,7 @@ } int ret = 0; - DavResource *ls = dav_query(sn, "select D:getetag,idav:status,idav:tags,idav:finfo,idav:xattributes,idav:content-hash from / with depth = infinity"); + DavResource *ls = dav_query(sn, "select D:getetag,idav:status,idav:tags,idav:finfo,idav:xattributes,`idav:content-hash` from / with depth = infinity"); if(!ls) { print_resource_error(sn, "/"); if(locked) { @@ -815,6 +822,8 @@ return REMOTE_NO_CHANGE; } + DavBool issplit = dav_get_property(res, "idav:split") ? TRUE : FALSE; + RemoteChangeType type = cmd_getoption(a, "conflict") ? REMOTE_CHANGE_MODIFIED : REMOTE_CHANGE_CONFLICT_LOCAL_MODIFIED; @@ -833,13 +842,19 @@ } RemoteChangeType ret = REMOTE_NO_CHANGE; - if(res->iscollection) { + if(res->iscollection && !issplit) { if(!exists) { ret = REMOTE_CHANGE_MKDIR; } } else if(local) { DavBool nochange = FALSE; - if(local->etag) { + char *content_hash = sync_get_content_hash(res); + + if(content_hash || local->hash) { + if(!nullstrcmp(content_hash, local->hash)) { + nochange = TRUE; + } + } else if(local->etag) { sstr_t e = sstr(etag); if(sstrprefix(e, S("W/"))) { e = sstrsubs(e, 2); @@ -958,10 +973,6 @@ if(ret == 0) { (*counter)++; - - if(sync_store_metadata(dir, tmp_path, local, res)) { - fprintf(stderr, "Cannot store metadata: %s\n", path); - } if(dir->trash && dir->backuppull) { move_to_trash(dir, local_path); @@ -989,6 +1000,10 @@ local->path = strdup(path); ucx_map_cstr_put(db->resources, local->path, local); } + + if(sync_store_metadata(dir, local_path, local, res)) { + fprintf(stderr, "Cannot store metadata: %s\n", path); + } if(local->etag) { free(local->etag);
--- a/libidav/utils.c Thu Mar 28 11:54:27 2019 +0100 +++ b/libidav/utils.c Thu Mar 28 14:18:54 2019 +0100 @@ -370,6 +370,34 @@ return sbuffer.length; } +int util_path_isrelated(const char *path1, const char *path2) { + scstr_t p1 = scstr(path1); + scstr_t p2 = scstr(path2); + + if(p1.ptr[p1.length-1] == '/') { + p1.length--; + } + if(p2.ptr[p2.length-1] == '/') { + p2.length--; + } + + if(p2.length < p1.length) { + return 0; + } + + if(!sstrcmp(p1, p2)) { + return 1; + } + + if(sstrprefix(p2, p1)) { + if(p2.ptr[p1.length] == '/') { + return 1; + } + } + + return 0; +} + void util_capture_header(CURL *handle, UcxMap* map) { if(map) { curl_easy_setopt(handle, CURLOPT_HEADERFUNCTION, util_header_callback);
--- a/libidav/utils.h Thu Mar 28 11:54:27 2019 +0100 +++ b/libidav/utils.h Thu Mar 28 14:18:54 2019 +0100 @@ -72,6 +72,11 @@ char* util_get_url(DavSession *sn, const char *href); void util_set_url(DavSession *sn, const char *href); +/* + * returns true if path1 and path2 are equal or if path2 is a child of path1 + */ +int util_path_isrelated(const char *path1, const char *path2); + void util_capture_header(CURL *handle, UcxMap* map); char* util_path_to_url(DavSession *sn, char *path);