Mon, 08 Sep 2025 12:10:13 +0200
add dav_resource_path_key
| dav/sync.c | file | annotate | diff | comparison | revisions | |
| libidav/resource.c | file | annotate | diff | comparison | revisions | |
| libidav/webdav.h | file | annotate | diff | comparison | revisions |
--- a/dav/sync.c Mon Sep 08 11:39:54 2025 +0200 +++ b/dav/sync.c Mon Sep 08 12:10:13 2025 +0200 @@ -682,6 +682,7 @@ return 1; } +// TODO: remove: use dav_resource_map void res2map(DavResource *root, CxMap *map) { CxList *stack = cxLinkedListCreateSimple(CX_STORE_POINTERS); cxListInsert(stack, 0, root->children); @@ -701,18 +702,6 @@ cxListFree(stack); } -static CxHashKey resource_path_key(DavResource *res) { - CxHashKey key = { NULL, 0, 0 }; - if(res && res->path) { - cxstring res_path = cx_str(res->path); - if(res_path.length > 0 && res_path.ptr[res_path.length-1] == '/') { - res_path.length--; - } - key = cx_hash_key(res_path.ptr, res_path.length); - } - return key; -} - int cmd_pull(CmdArgs *a, DavBool incoming) { if(a->argc != 1) { fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few" : "many"); @@ -925,7 +914,7 @@ // remove every server resource from dbres // all remaining elements are the resources that are removed // on the server - cxMapRemove(dbres, resource_path_key(res)); + cxMapRemove(dbres, dav_resource_path_key(res)); if(!dav_get_property_ns(res, DAV_NS, "split") && res->children) { cxListInsert(stack, 0, res->children); @@ -1073,7 +1062,7 @@ break; } - LocalResource *local = cxMapGet(db->resources, resource_path_key(res)); + LocalResource *local = cxMapGet(db->resources, dav_resource_path_key(res)); if(local) { log_printf("update: %s\n", res->path); char *res_path = resource_local_path(res); @@ -1199,7 +1188,7 @@ RemoteChangeType type = cmd_getoption(a, "conflict") ? REMOTE_CHANGE_MODIFIED : REMOTE_CHANGE_CONFLICT_LOCAL_MODIFIED; - LocalResource *local = cxMapGet(db->resources, resource_path_key(res)); + LocalResource *local = cxMapGet(db->resources, dav_resource_path_key(res)); char *local_path = create_local_path(dir, res->path); char *link = SYNC_SYMLINK(dir) ?
--- a/libidav/resource.c Mon Sep 08 11:39:54 2025 +0200 +++ b/libidav/resource.c Mon Sep 08 12:10:13 2025 +0200 @@ -281,6 +281,18 @@ return resource->href; } +CxHashKey dav_resource_path_key(DavResource *res) { + CxHashKey key = { NULL, 0, 0 }; + if(res && res->path) { + cxstring res_path = cx_str(res->path); + if(res_path.length > 0 && res_path.ptr[res_path.length-1] == '/') { + res_path.length--; + } + key = cx_hash_key(res_path.ptr, res_path.length); + } + return key; +} + CxTreeIterator dav_resource_iterator(DavResource *res) { return cx_tree_iterator(res, FALSE, offsetof(DavResource, children), offsetof(DavResource, next)); }
--- a/libidav/webdav.h Mon Sep 08 11:39:54 2025 +0200 +++ b/libidav/webdav.h Mon Sep 08 12:10:13 2025 +0200 @@ -338,6 +338,8 @@ char* dav_resource_get_href(DavResource *resource); +CxHashKey dav_resource_path_key(DavResource *res); + CxTreeIterator dav_resource_iterator(DavResource *res); CxTreeVisitor dav_resource_visitor(DavResource *res); CxMap* dav_resource_map(DavResource *res);