diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-07-29 19:16:04 +0300 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-07-29 19:16:04 +0300 |
commit | 7b05eef61f08f0f34266ac3af4ae22fc72dbc269 (patch) | |
tree | 43fe57eeb28cdb6819729d331af36005b33c5ad2 /src/archive.c | |
parent | 2887e04cd7ea8fcc3e0815a11db6899d1c9535bf (diff) | |
download | apk-tools-7b05eef61f08f0f34266ac3af4ae22fc72dbc269.tar.gz apk-tools-7b05eef61f08f0f34266ac3af4ae22fc72dbc269.tar.bz2 apk-tools-7b05eef61f08f0f34266ac3af4ae22fc72dbc269.tar.xz apk-tools-7b05eef61f08f0f34266ac3af4ae22fc72dbc269.zip |
tar: make checksumming of inner files conditional
and force checksumming only when unpacking archive. otherwise
it's extra computation for nothing.
Diffstat (limited to 'src/archive.c')
-rw-r--r-- | src/archive.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/archive.c b/src/archive.c index 68ec287..dca99fd 100644 --- a/src/archive.c +++ b/src/archive.c @@ -114,7 +114,7 @@ static void tar_entry_close(void *stream) } int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser, - void *ctx) + void *ctx, int soft_checksums) { struct apk_file_info entry; struct apk_tar_entry_istream teis = { @@ -152,6 +152,7 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser, .device = makedev(GET_OCTAL(buf.devmajor), GET_OCTAL(buf.devminor)), }; + teis.csum = NULL; switch (buf.typeflag) { case 'L': @@ -170,8 +171,7 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser, di->size <= sizeof(entry.csum.data)) { entry.csum.type = di->size; memcpy(entry.csum.data, di->digest, di->size); - teis.csum = NULL; - } else { + } else if (soft_checksums) { teis.csum = &entry.csum; } break; @@ -202,7 +202,10 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser, entry.name = strdup(buf.name); /* callback parser function */ - EVP_DigestInit_ex(&teis.mdctx, apk_default_checksum(), NULL); + if (teis.csum != NULL) + EVP_DigestInit_ex(&teis.mdctx, + apk_default_checksum(), NULL); + r = parser(ctx, &entry, &teis.is); free(entry.name); if (r != 0) |