summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2008-11-07 19:18:53 +0200
committerTimo Teras <timo.teras@iki.fi>2008-11-07 19:18:53 +0200
commit791cf6f05bc71118925343528edd44fd4a671bb3 (patch)
tree5107b32f40d8100aeaea7ab7466338b6d9bae896 /src/io.c
parent0bf7a1a2cc45086d594e4af64e1e1a8c96274f47 (diff)
downloadapk-tools-791cf6f05bc71118925343528edd44fd4a671bb3.tar.gz
apk-tools-791cf6f05bc71118925343528edd44fd4a671bb3.tar.bz2
apk-tools-791cf6f05bc71118925343528edd44fd4a671bb3.tar.xz
apk-tools-791cf6f05bc71118925343528edd44fd4a671bb3.zip
pkg: speed up indexing of version 2 .apks
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/io.c b/src/io.c
index 81e3de3..418c7f8 100644
--- a/src/io.c
+++ b/src/io.c
@@ -183,12 +183,22 @@ static void is_bs_close(void *stream, csum_t csum)
struct apk_istream_bstream *isbs =
container_of(stream, struct apk_istream_bstream, bs);
- if (csum != NULL)
+ if (csum != NULL) {
+ size_t size;
+
+ do {
+ size = isbs->is->read(isbs->is, isbs->buffer,
+ sizeof(isbs->buffer));
+ csum_process(&isbs->csum_ctx, isbs->buffer, size);
+ } while (size == sizeof(isbs->buffer));
+
csum_finish(&isbs->csum_ctx, csum);
+ }
isbs->is->close(isbs->is);
free(isbs);
}
+
struct apk_bstream *apk_bstream_from_istream(struct apk_istream *istream)
{
struct apk_istream_bstream *isbs;
@@ -238,8 +248,12 @@ static void mmap_close(void *stream, csum_t csum)
struct apk_mmap_bstream *mbs =
container_of(stream, struct apk_mmap_bstream, bs);
- if (csum != NULL)
+ if (csum != NULL) {
+ if (mbs->pos != mbs->size)
+ csum_process(&mbs->csum_ctx, &mbs->ptr[mbs->pos],
+ mbs->size - mbs->pos);
csum_finish(&mbs->csum_ctx, csum);
+ }
munmap(mbs->ptr, mbs->size);
free(mbs);