dav/sync.c

changeset 614
e72d2b99b0f6
parent 613
f6072141f5ee
child 615
ab669d21f82a
equal deleted inserted replaced
613:f6072141f5ee 614:e72d2b99b0f6
1876 ls_modified = ucx_list_append(ls_modified, local_res); 1876 ls_modified = ucx_list_append(ls_modified, local_res);
1877 } 1877 }
1878 } else if(local_res->metadata_updated) { 1878 } else if(local_res->metadata_updated) {
1879 ls_update = ucx_list_append(ls_update, local_res); 1879 ls_update = ucx_list_append(ls_update, local_res);
1880 } 1880 }
1881
1882 if(local_res->isnew) {
1883 if(local_resource_load_metadata(dir, local_res)) {
1884 fprintf(
1885 stderr,
1886 "Failed to load metadata: %s\n",
1887 local_resource_path(local_res));
1888 }
1889 }
1881 } 1890 }
1882 1891
1883 if(dir->hashing) { 1892 if(dir->hashing) {
1884 // calculate hashes of all new files and check if a file 1893 // calculate hashes of all new files and check if a file
1885 // was moved or is a copy 1894 // was moved or is a copy
2711 res->metadata_updated = 1; 2720 res->metadata_updated = 1;
2712 } 2721 }
2713 } 2722 }
2714 2723
2715 if((dir->metadata & FINFO_XATTR) == FINFO_XATTR) { 2724 if((dir->metadata & FINFO_XATTR) == FINFO_XATTR) {
2716 char *path = create_local_path(dir, db_res->path); 2725 char *path = create_local_path(dir, local_resource_path(db_res));
2717 XAttributes *xattr = file_get_attributes(path); 2726 XAttributes *xattr = file_get_attributes(path);
2718 // test if xattr are added, removed or changed 2727 // test if xattr are added, removed or changed
2719 if((db_res->xattr_hash && !xattr) || 2728 if((db_res->xattr_hash && !xattr) ||
2720 (!db_res->xattr_hash && xattr) || 2729 (!db_res->xattr_hash && xattr) ||
2721 (xattr && db_res->xattr_hash && strcmp(xattr->hash, db_res->xattr_hash))) 2730 (xattr && db_res->xattr_hash && strcmp(xattr->hash, db_res->xattr_hash)))
2796 // something weird is happening, the server must support etags 2805 // something weird is happening, the server must support etags
2797 fprintf(stderr, "Warning: resource %s has no etag\n", remote->href); 2806 fprintf(stderr, "Warning: resource %s has no etag\n", remote->href);
2798 } 2807 }
2799 } 2808 }
2800 return ret; 2809 return ret;
2810 }
2811
2812 int local_resource_load_metadata(SyncDirectory *dir, LocalResource *res) {
2813 // currently only xattr needed
2814 if((dir->metadata & FINFO_XATTR) == FINFO_XATTR) {
2815 char *path = create_local_path(dir, local_resource_path(res));
2816 XAttributes *xattr = file_get_attributes(path);
2817 res->xattr = xattr;
2818 free(path);
2819 }
2820
2821 return 0;
2801 } 2822 }
2802 2823
2803 char* resource_local_path(DavResource *res) { 2824 char* resource_local_path(DavResource *res) {
2804 #ifdef SYS_LINK_EXT 2825 #ifdef SYS_LINK_EXT
2805 // on Windows, add .lnk extension to links 2826 // on Windows, add .lnk extension to links

mercurial