Sat, 10 Aug 2019 14:25:03 +0200
fix xattr not synced for new files
dav/finfo.c | file | annotate | diff | comparison | revisions | |
dav/sync.c | file | annotate | diff | comparison | revisions | |
dav/sync.h | file | annotate | diff | comparison | revisions |
--- a/dav/finfo.c Sat Aug 10 13:48:14 2019 +0200 +++ b/dav/finfo.c Sat Aug 10 14:25:03 2019 +0200 @@ -46,7 +46,7 @@ scstr_t s = scstr(str); if(!sstrcmp(s, SC("*")) || !sstrcmp(s, SC("a")) || !sstrcmp(s, SC("all"))) { - return FINFO_DATE|FINFO_OWNER|FINFO_MODE; + return FINFO_DATE|FINFO_OWNER|FINFO_MODE|FINFO_XATTR; } ssize_t count = 0;
--- a/dav/sync.c Sat Aug 10 13:48:14 2019 +0200 +++ b/dav/sync.c Sat Aug 10 14:25:03 2019 +0200 @@ -1878,6 +1878,15 @@ } else if(local_res->metadata_updated) { ls_update = ucx_list_append(ls_update, local_res); } + + if(local_res->isnew) { + if(local_resource_load_metadata(dir, local_res)) { + fprintf( + stderr, + "Failed to load metadata: %s\n", + local_resource_path(local_res)); + } + } } if(dir->hashing) { @@ -2713,7 +2722,7 @@ } if((dir->metadata & FINFO_XATTR) == FINFO_XATTR) { - char *path = create_local_path(dir, db_res->path); + char *path = create_local_path(dir, local_resource_path(db_res)); XAttributes *xattr = file_get_attributes(path); // test if xattr are added, removed or changed if((db_res->xattr_hash && !xattr) || @@ -2800,6 +2809,18 @@ return ret; } +int local_resource_load_metadata(SyncDirectory *dir, LocalResource *res) { + // 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); + res->xattr = xattr; + free(path); + } + + return 0; +} + char* resource_local_path(DavResource *res) { #ifdef SYS_LINK_EXT // on Windows, add .lnk extension to links
--- a/dav/sync.h Sat Aug 10 13:48:14 2019 +0200 +++ b/dav/sync.h Sat Aug 10 14:25:03 2019 +0200 @@ -151,6 +151,7 @@ SyncDatabase *db, DavResource *remote, LocalResource *res); +int local_resource_load_metadata(SyncDirectory *dir, LocalResource *res); char* resource_local_path(DavResource *res); size_t resource_get_blocksize(SyncDirectory *dir, LocalResource *local, DavResource *res, off_t filesize);