dav/db.c

changeset 681
3320429502cf
parent 667
6cdcd3e4e368
child 692
56b66fe2b4f5
equal deleted inserted replaced
680:e66f2645be65 681:3320429502cf
737 737
738 static char* nullstrdup(const char *s) { 738 static char* nullstrdup(const char *s) {
739 return s ? strdup(s) : NULL; 739 return s ? strdup(s) : NULL;
740 } 740 }
741 741
742 void local_resource_copy_parts(LocalResource *from, LocalResource *to) {
743 if(from->parts) {
744 to->numparts = from->numparts;
745 to->parts = calloc(from->numparts, sizeof(FilePart));
746 for(int i=0;i<to->numparts;i++) {
747 FilePart s = from->parts[i];
748 FilePart p;
749 p.block = s.block;
750 p.hash = nullstrdup(s.hash);
751 p.etag = nullstrdup(s.etag);
752 to->parts[i] = p;
753 }
754 }
755 }
756
742 LocalResource* local_resource_copy(LocalResource *src, const char *new_path) { 757 LocalResource* local_resource_copy(LocalResource *src, const char *new_path) {
743 LocalResource *newres = calloc(1, sizeof(LocalResource)); 758 LocalResource *newres = calloc(1, sizeof(LocalResource));
744 newres->path = strdup(new_path); 759 newres->path = strdup(new_path);
745 newres->etag = nullstrdup(src->etag); 760 newres->etag = nullstrdup(src->etag);
746 newres->hash = nullstrdup(src->hash); 761 newres->hash = nullstrdup(src->hash);
767 782
768 newres->tags_hash = nullstrdup(src->tags_hash); 783 newres->tags_hash = nullstrdup(src->tags_hash);
769 newres->xattr_hash = nullstrdup(src->xattr_hash); 784 newres->xattr_hash = nullstrdup(src->xattr_hash);
770 newres->remote_tags_hash = nullstrdup(src->remote_tags_hash); 785 newres->remote_tags_hash = nullstrdup(src->remote_tags_hash);
771 786
772 if(src->parts) { 787 local_resource_copy_parts(src, newres);
773 newres->numparts = src->numparts;
774 newres->parts = calloc(src->numparts, sizeof(FilePart));
775 for(int i=0;i<newres->numparts;i++) {
776 FilePart s = src->parts[i];
777 FilePart p;
778 p.block = s.block;
779 p.hash = nullstrdup(s.hash);
780 p.etag = nullstrdup(s.etag);
781 newres->parts[i] = p;
782 }
783 }
784 788
785 newres->blocksize = src->blocksize; 789 newres->blocksize = src->blocksize;
786 790
787 newres->tags_updated = src->tags_updated; 791 newres->tags_updated = src->tags_updated;
788 newres->finfo_updated = src->finfo_updated; 792 newres->finfo_updated = src->finfo_updated;

mercurial