# HG changeset patch # User Olaf Wintermann # Date 1565465527 -7200 # Node ID 4b34d12cf211437174f3b568f7ab4cae5811fc8f # Parent 1c995e93bf40dd2b8092ad958bd30a7d9f047501 exclude tag xattr from xattribute sync diff -r 1c995e93bf40 -r 4b34d12cf211 dav/finfo.c --- a/dav/finfo.c Sat Aug 10 19:54:37 2019 +0200 +++ b/dav/finfo.c Sat Aug 10 21:32:07 2019 +0200 @@ -138,13 +138,13 @@ char *hash = NULL; DavXmlNode *node = xml; - while(node) { + for(;node;node=node->next) { if(node->type == DAV_XML_ELEMENT) { if(!strcmp(node->name, "hash")) { hash = dav_xml_getstring(node->children); } else if(!strcmp(node->name, "xattr")) { char *xattr_name = dav_xml_get_attr(node, "name"); - if(xattr_name) { + if(xattr_name) { names = ucx_list_append(names, strdup(xattr_name)); char *text = dav_xml_getstring(node->children); @@ -165,8 +165,6 @@ } } } - - node = node->next; } XAttributes *attributes = NULL; @@ -190,7 +188,11 @@ return attributes; } -XAttributes* file_get_attributes(const char *path) { +XAttributes* file_get_attributes( + const char *path, + xattr_filter_func filter, + void *filterdata) +{ ssize_t nelm = 0; char **attributes = xattr_list(path, &nelm); if(nelm <= 0) { @@ -206,6 +208,14 @@ size_t nattr = 0; for(int i=0;i= 0) { diff -r 1c995e93bf40 -r 4b34d12cf211 dav/finfo.h --- a/dav/finfo.h Sat Aug 10 19:54:37 2019 +0200 +++ b/dav/finfo.h Sat Aug 10 21:32:07 2019 +0200 @@ -62,13 +62,18 @@ DavBool gid_set; } FileInfo; +typedef int(*xattr_filter_func)(const char*,void*); + uint32_t parse_finfo_settings(const char *str, char **unknown); int resource_set_finfo(const char *path, DavResource *res, uint32_t finfo); int resource_set_finfo_s(struct stat *s, DavResource *res, uint32_t finfo); XAttributes* xml_get_attributes(DavXmlNode *xml); -XAttributes* file_get_attributes(const char *path); +XAttributes* file_get_attributes( + const char *path, + xattr_filter_func filter, + void *filterdata); int resource_set_xattr(DavResource *res, XAttributes *xattr); void xattributes_free(XAttributes *xattr); diff -r 1c995e93bf40 -r 4b34d12cf211 dav/main.c --- a/dav/main.c Sat Aug 10 19:54:37 2019 +0200 +++ b/dav/main.c Sat Aug 10 21:32:07 2019 +0200 @@ -1528,7 +1528,7 @@ fprintf(stderr, "Cannot set finfo: %s.\n", strerror(errno)); } if((finfo & FINFO_XATTR) == FINFO_XATTR) { - XAttributes *xattr = file_get_attributes(fpath); + XAttributes *xattr = file_get_attributes(fpath, NULL, NULL); if(xattr) { resource_set_xattr(res, xattr); } diff -r 1c995e93bf40 -r 4b34d12cf211 dav/sync.c --- a/dav/sync.c Sat Aug 10 19:54:37 2019 +0200 +++ b/dav/sync.c Sat Aug 10 21:32:07 2019 +0200 @@ -459,7 +459,18 @@ if(local) { local->keep = TRUE; } - +} + +static int xattr_filter(const char *name, SyncDirectory *dir) { + // exclude tag xattr + if( + dir->tagconfig && + dir->tagconfig->store == TAG_STORE_XATTR && + !strcmp(dir->tagconfig->xattr_name, name)) + { + return 0; + } + return 1; } void res2map(DavResource *root, UcxMap *map) { @@ -2731,7 +2742,7 @@ if((dir->metadata & FINFO_XATTR) == FINFO_XATTR) { char *path = create_local_path(dir, local_resource_path(db_res)); - XAttributes *xattr = file_get_attributes(path); + XAttributes *xattr = file_get_attributes(path, (xattr_filter_func)xattr_filter, dir); // test if xattr are added, removed or changed if((db_res->xattr_hash && !xattr) || (!db_res->xattr_hash && xattr) || @@ -2825,7 +2836,7 @@ // currently only xattr needed if((dir->metadata & FINFO_XATTR) == FINFO_XATTR) { char *path = create_local_path(dir, local_resource_path(res)); - XAttributes *xattr = file_get_attributes(path); + XAttributes *xattr = file_get_attributes(path, (xattr_filter_func)xattr_filter, dir); res->xattr = xattr; free(path); } @@ -3184,7 +3195,7 @@ } } - if(!ret) { + if(!ret && local) { local->tags_updated = 0; } @@ -3247,7 +3258,7 @@ } else { if(changed) *changed = TRUE; } - if(!newhash) { + if(newhash) { *newhash = new_hash; } else { free(newhash);