dav/sync.c

changeset 545
268157722a0e
parent 544
9e85e1ec1155
child 546
33e312dd851d
equal deleted inserted replaced
544:9e85e1ec1155 545:268157722a0e
1071 } 1071 }
1072 issplit = TRUE; 1072 issplit = TRUE;
1073 } 1073 }
1074 UcxList *part_updates = NULL; 1074 UcxList *part_updates = NULL;
1075 uint64_t blockcount = 0; 1075 uint64_t blockcount = 0;
1076 char *content_hash = NULL;
1076 1077
1077 if(res->iscollection && !issplit) { 1078 if(res->iscollection && !issplit) {
1078 // why are we here? 1079 // why are we here?
1079 return 0; 1080 return 0;
1080 } 1081 }
1112 part_updates = sync_download_changed_parts(res, local, out, blocksize, &blockcount, &truncate_file, &ret); 1113 part_updates = sync_download_changed_parts(res, local, out, blocksize, &blockcount, &truncate_file, &ret);
1113 } else { 1114 } else {
1114 ret = dav_get_content(res, out, (dav_write_func)fwrite); 1115 ret = dav_get_content(res, out, (dav_write_func)fwrite);
1115 } 1116 }
1116 fclose(out); 1117 fclose(out);
1117 if(truncate_file >= 0) { 1118
1118 truncate(tmp_path, truncate_file); 1119 if(issplit) {
1120 if(truncate_file >= 0) {
1121 truncate(tmp_path, truncate_file);
1122 }
1123
1124 char *res_hash = sync_get_content_hash(res);
1125 if(res_hash) {
1126 content_hash = res_hash;
1127 } else {
1128 content_hash = util_file_hash(local_path);
1129 }
1119 } 1130 }
1120 1131
1121 if(ret == 0) { 1132 if(ret == 0) {
1122 (*counter)++; 1133 (*counter)++;
1123 1134
1155 } 1166 }
1156 1167
1157 if(local->etag) { 1168 if(local->etag) {
1158 free(local->etag); 1169 free(local->etag);
1159 } 1170 }
1171 if(local->hash) {
1172 free(local->hash);
1173 }
1160 1174
1161 update_parts(local, part_updates, blockcount); 1175 update_parts(local, part_updates, blockcount);
1162 1176
1163 // set metadata from stat 1177 // set metadata from stat
1164 local->etag = strdup(etag); 1178 local->etag = strdup(etag);
1179 if(content_hash) {
1180 local->hash = content_hash;
1181 }
1165 sync_set_metadata_from_stat(local, &s); 1182 sync_set_metadata_from_stat(local, &s);
1166 local->skipped = FALSE; 1183 local->skipped = FALSE;
1167 } else if(tmp_path) { 1184 } else if(tmp_path) {
1168 if(sys_unlink(tmp_path)) { 1185 if(sys_unlink(tmp_path)) {
1169 fprintf(stderr, "Cannot remove tmp file: %s\n", tmp_path); 1186 fprintf(stderr, "Cannot remove tmp file: %s\n", tmp_path);

mercurial