dav/sync.c

changeset 618
4b34d12cf211
parent 617
1c995e93bf40
child 619
1d20a6cab2e5
equal deleted inserted replaced
617:1c995e93bf40 618:4b34d12cf211
457 static void localres_keep(SyncDatabase *db, const char *path) { 457 static void localres_keep(SyncDatabase *db, const char *path) {
458 LocalResource *local = ucx_map_cstr_remove(db->resources, path); 458 LocalResource *local = ucx_map_cstr_remove(db->resources, path);
459 if(local) { 459 if(local) {
460 local->keep = TRUE; 460 local->keep = TRUE;
461 } 461 }
462 462 }
463
464 static int xattr_filter(const char *name, SyncDirectory *dir) {
465 // exclude tag xattr
466 if(
467 dir->tagconfig &&
468 dir->tagconfig->store == TAG_STORE_XATTR &&
469 !strcmp(dir->tagconfig->xattr_name, name))
470 {
471 return 0;
472 }
473 return 1;
463 } 474 }
464 475
465 void res2map(DavResource *root, UcxMap *map) { 476 void res2map(DavResource *root, UcxMap *map) {
466 UcxList *stack = ucx_list_prepend(NULL, root->children); 477 UcxList *stack = ucx_list_prepend(NULL, root->children);
467 while(stack) { 478 while(stack) {
2729 } 2740 }
2730 } 2741 }
2731 2742
2732 if((dir->metadata & FINFO_XATTR) == FINFO_XATTR) { 2743 if((dir->metadata & FINFO_XATTR) == FINFO_XATTR) {
2733 char *path = create_local_path(dir, local_resource_path(db_res)); 2744 char *path = create_local_path(dir, local_resource_path(db_res));
2734 XAttributes *xattr = file_get_attributes(path); 2745 XAttributes *xattr = file_get_attributes(path, (xattr_filter_func)xattr_filter, dir);
2735 // test if xattr are added, removed or changed 2746 // test if xattr are added, removed or changed
2736 if((db_res->xattr_hash && !xattr) || 2747 if((db_res->xattr_hash && !xattr) ||
2737 (!db_res->xattr_hash && xattr) || 2748 (!db_res->xattr_hash && xattr) ||
2738 (xattr && db_res->xattr_hash && strcmp(xattr->hash, db_res->xattr_hash))) 2749 (xattr && db_res->xattr_hash && strcmp(xattr->hash, db_res->xattr_hash)))
2739 { 2750 {
2823 2834
2824 int local_resource_load_metadata(SyncDirectory *dir, LocalResource *res) { 2835 int local_resource_load_metadata(SyncDirectory *dir, LocalResource *res) {
2825 // currently only xattr needed 2836 // currently only xattr needed
2826 if((dir->metadata & FINFO_XATTR) == FINFO_XATTR) { 2837 if((dir->metadata & FINFO_XATTR) == FINFO_XATTR) {
2827 char *path = create_local_path(dir, local_resource_path(res)); 2838 char *path = create_local_path(dir, local_resource_path(res));
2828 XAttributes *xattr = file_get_attributes(path); 2839 XAttributes *xattr = file_get_attributes(path, (xattr_filter_func)xattr_filter, dir);
2829 res->xattr = xattr; 2840 res->xattr = xattr;
2830 free(path); 2841 free(path);
2831 } 2842 }
2832 2843
2833 return 0; 2844 return 0;
3182 // ignore errors on remove 3193 // ignore errors on remove
3183 xattr_remove(path, dir->tagconfig->xattr_name); 3194 xattr_remove(path, dir->tagconfig->xattr_name);
3184 } 3195 }
3185 } 3196 }
3186 3197
3187 if(!ret) { 3198 if(!ret && local) {
3188 local->tags_updated = 0; 3199 local->tags_updated = 0;
3189 } 3200 }
3190 3201
3191 return ret; 3202 return ret;
3192 } 3203 }
3245 } 3256 }
3246 free(res->tags_hash); 3257 free(res->tags_hash);
3247 } else { 3258 } else {
3248 if(changed) *changed = TRUE; 3259 if(changed) *changed = TRUE;
3249 } 3260 }
3250 if(!newhash) { 3261 if(newhash) {
3251 *newhash = new_hash; 3262 *newhash = new_hash;
3252 } else { 3263 } else {
3253 free(newhash); 3264 free(newhash);
3254 } 3265 }
3255 3266

mercurial