diff --git a/src/lib/dl/dl.c b/src/lib/dl/dl.c index 402857f..d7c70e4 100644 --- a/src/lib/dl/dl.c +++ b/src/lib/dl/dl.c @@ -248,10 +248,16 @@ bool ZCK_PUBLIC_API zck_copy_chunks(zckCtx *src, zckCtx *tgt) { } zckChunk *f = NULL; - HASH_FIND(hh, src_info->ht, tgt_idx->digest, tgt_idx->digest_size, f); - if(f && f->length == tgt_idx->length && - f->comp_length == tgt_idx->comp_length) + /* If both archives has uncompressed data digests, check them instead of the compressed ones */ + if(src->has_uncompressed_source && tgt->has_uncompressed_source){ + HASH_FIND(hhuncomp, src_info->htuncomp, tgt_idx->digest_uncompressed, tgt_idx->digest_size, f); + }else{ + HASH_FIND(hh, src_info->ht, tgt_idx->digest, tgt_idx->digest_size, f); + } + + if(f && f->length == tgt_idx->length) write_and_verify_chunk(src, tgt, f, tgt_idx); + tgt_idx = tgt_idx->next; } return true; @@ -279,13 +285,14 @@ bool ZCK_PUBLIC_API zck_find_matching_chunks(zckCtx *src, zckCtx *tgt) { } /* - * Compare digest for compressed data if the same compressor + * Compare digest for uncompressed data if both archives support it, + * otherwise compare digest for compressed data if the same compressor * was iused */ - if (src->comp.type == tgt->comp.type) { - HASH_FIND(hh, src_info->ht, tgt_idx->digest, tgt_idx->digest_size, f); - } else if (src->has_uncompressed_source && tgt->has_uncompressed_source) { + if (src->has_uncompressed_source && tgt->has_uncompressed_source) { HASH_FIND(hhuncomp, src_info->htuncomp, tgt_idx->digest_uncompressed, tgt_idx->digest_size, f); + }else if (src->comp.type == tgt->comp.type) { + HASH_FIND(hh, src_info->ht, tgt_idx->digest, tgt_idx->digest_size, f); } else { } diff --git a/src/lib/index/index_read.c b/src/lib/index/index_read.c index 6ec0a8d..0a52507 100644 --- a/src/lib/index/index_read.c +++ b/src/lib/index/index_read.c @@ -271,11 +271,19 @@ bool ZCK_PUBLIC_API zck_compare_chunk_digest(zckChunk *a, zckChunk *b) { } else { ALLOCD_BOOL(NULL, b); } - + if(a->digest_size != b->digest_size) return false; - if(memcmp(a->digest, b->digest, a->digest_size) != 0) - return false; + + if(a->zck->has_uncompressed_source && b->zck->has_uncompressed_source){ + /* If both archives has uncompressed digest, compare them instead */ + if(memcmp(a->digest_uncompressed, b->digest_uncompressed, a->digest_size) != 0) + return false; + }else { + if(memcmp(a->digest, b->digest, a->digest_size) != 0) + return false; + } + return true; }