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); |