--- a/dav/db.c Wed Nov 20 08:44:26 2019 +0100 +++ b/dav/db.c Wed Nov 20 11:57:45 2019 +0100 @@ -739,6 +739,21 @@ return s ? strdup(s) : NULL; } +void local_resource_copy_parts(LocalResource *from, LocalResource *to) { + if(from->parts) { + to->numparts = from->numparts; + to->parts = calloc(from->numparts, sizeof(FilePart)); + for(int i=0;i<to->numparts;i++) { + FilePart s = from->parts[i]; + FilePart p; + p.block = s.block; + p.hash = nullstrdup(s.hash); + p.etag = nullstrdup(s.etag); + to->parts[i] = p; + } + } +} + LocalResource* local_resource_copy(LocalResource *src, const char *new_path) { LocalResource *newres = calloc(1, sizeof(LocalResource)); newres->path = strdup(new_path); @@ -769,18 +784,7 @@ newres->xattr_hash = nullstrdup(src->xattr_hash); newres->remote_tags_hash = nullstrdup(src->remote_tags_hash); - if(src->parts) { - newres->numparts = src->numparts; - newres->parts = calloc(src->numparts, sizeof(FilePart)); - for(int i=0;i<newres->numparts;i++) { - FilePart s = src->parts[i]; - FilePart p; - p.block = s.block; - p.hash = nullstrdup(s.hash); - p.etag = nullstrdup(s.etag); - newres->parts[i] = p; - } - } + local_resource_copy_parts(src, newres); newres->blocksize = src->blocksize;