Sat, 20 Apr 2019 17:47:40 +0200
store link property on push
dav/db.h | file | annotate | diff | comparison | revisions | |
dav/sync.c | file | annotate | diff | comparison | revisions |
--- a/dav/db.h Sat Apr 20 12:31:08 2019 +0200 +++ b/dav/db.h Sat Apr 20 17:47:40 2019 +0200 @@ -79,6 +79,7 @@ DavBool finfo_updated; DavBool xattr_updated; DavBool metadata_updated; + DavBool link_updated; DavBool keep; DavBool restore;
--- a/dav/sync.c Sat Apr 20 12:31:08 2019 +0200 +++ b/dav/sync.c Sat Apr 20 17:47:40 2019 +0200 @@ -81,9 +81,10 @@ { DAV_NS, "tags" }, { DAV_NS, "xattributes" }, { DAV_NS, "content-hash" }, - { DAV_NS, "split" } + { DAV_NS, "split" }, + { DAV_NS, "link" } }; -static size_t numdefprops = 6; +static size_t numdefprops = 8 ; /* * strcmp version that works with NULL pointers @@ -1763,7 +1764,7 @@ LocalResource *local = elm->data; UcxList *prev = elm->prev; UcxList *next = elm->next; - if(local->isdirectory) { + if(local->isdirectory || local->link_target) { elm = elm->next; continue; } @@ -2556,9 +2557,11 @@ } } - if(db_res->last_modified == res->last_modified && db_res->size == res->size) { + if(nullstrcmp(db_res->link_target, res->link_target)) { + res->link_updated = 1; + } else if(db_res->last_modified == res->last_modified && db_res->size == res->size) { return 0; - } + } if(db_res->parts) { // if the resource is splitted, move the part infos to the new @@ -2590,9 +2593,10 @@ {DAV_NS, "tags"}, {DAV_NS, "version-collection"}, {DAV_NS, "content-hash"}, - {DAV_NS, "split" } + {DAV_NS, "split" }, + {DAV_NS, "link" } }; - int err = dav_load_prop(remote, properties, 4); + int err = dav_load_prop(remote, properties, 6); if(res->restore) { return 0; @@ -3479,6 +3483,11 @@ return -1; } + DavBool islink = local->link_target ? 1 : 0; + if(!local->link_target && local->link_updated) { + dav_remove_property_ns(res, DAV_NS, "link"); + } + size_t split_blocksize = resource_get_blocksize(dir, local, res, s.st_size); FILE *in = sys_fopen(local_path, "rb"); @@ -3492,11 +3501,10 @@ int split_err = 0; UcxList *parts = NULL; uint64_t blockcount = 0; - if(!issplit) { - // regular file upload - dav_set_content(res, in, (dav_read_func)myread, (dav_seek_func)file_seek); - dav_set_content_length(res, s.st_size); - } else { + + if(islink) { + dav_set_string_property_ns(res, DAV_NS, "link", local->link_target); + } else if(issplit) { // set split property char blocksize_str[32]; snprintf(blocksize_str, 32, "%zu", split_blocksize); @@ -3511,6 +3519,10 @@ split_blocksize, &blockcount, &split_err); + } else { + // regular file upload + dav_set_content(res, in, (dav_read_func)myread, (dav_seek_func)file_seek); + dav_set_content_length(res, s.st_size); } if(split_err) { free(local_path); @@ -3563,7 +3575,7 @@ if(up_res) { // the new content length must be equal or greater than the file size - if(up_res->contentlength < s.st_size && !issplit) { + if(up_res->contentlength < s.st_size && !issplit && !islink) { fprintf(stderr, "Incomplete Upload: %s\n", local_path); ret = -1; // try to set the resource status to 'broken'