pkg: speed up indexing of version 2 .apks
parent
0bf7a1a2cc
commit
791cf6f05b
18
src/io.c
18
src/io.c
|
@ -183,12 +183,22 @@ static void is_bs_close(void *stream, csum_t csum)
|
||||||
struct apk_istream_bstream *isbs =
|
struct apk_istream_bstream *isbs =
|
||||||
container_of(stream, struct apk_istream_bstream, bs);
|
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);
|
csum_finish(&isbs->csum_ctx, csum);
|
||||||
|
}
|
||||||
|
|
||||||
isbs->is->close(isbs->is);
|
isbs->is->close(isbs->is);
|
||||||
free(isbs);
|
free(isbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct apk_bstream *apk_bstream_from_istream(struct apk_istream *istream)
|
struct apk_bstream *apk_bstream_from_istream(struct apk_istream *istream)
|
||||||
{
|
{
|
||||||
struct apk_istream_bstream *isbs;
|
struct apk_istream_bstream *isbs;
|
||||||
|
@ -238,8 +248,12 @@ static void mmap_close(void *stream, csum_t csum)
|
||||||
struct apk_mmap_bstream *mbs =
|
struct apk_mmap_bstream *mbs =
|
||||||
container_of(stream, struct apk_mmap_bstream, bs);
|
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);
|
csum_finish(&mbs->csum_ctx, csum);
|
||||||
|
}
|
||||||
|
|
||||||
munmap(mbs->ptr, mbs->size);
|
munmap(mbs->ptr, mbs->size);
|
||||||
free(mbs);
|
free(mbs);
|
||||||
|
|
|
@ -54,8 +54,10 @@ static apk_blob_t trim(apk_blob_t str)
|
||||||
if (str.ptr == NULL || str.len < 1)
|
if (str.ptr == NULL || str.len < 1)
|
||||||
return str;
|
return str;
|
||||||
|
|
||||||
if (str.ptr[str.len-2] == '\n')
|
if (str.ptr[str.len-1] == '\n') {
|
||||||
|
str.ptr[str.len-1] = 0;
|
||||||
return APK_BLOB_PTR_LEN(str.ptr, str.len-1);
|
return APK_BLOB_PTR_LEN(str.ptr, str.len-1);
|
||||||
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -281,9 +283,9 @@ static int read_info_entry(void *ctx, const struct apk_archive_entry *ae,
|
||||||
apk_blob_t blob = apk_blob_from_istream(is, ae->size);
|
apk_blob_t blob = apk_blob_from_istream(is, ae->size);
|
||||||
apk_blob_for_each_segment(blob, "\n", read_info_line, ctx);
|
apk_blob_for_each_segment(blob, "\n", read_info_line, ctx);
|
||||||
free(blob.ptr);
|
free(blob.ptr);
|
||||||
/* FIXME: all done after checking if .INSTALL exists */
|
return 1;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
/* FIXME: Check for .INSTALL */
|
||||||
} else if (strncmp(ae->name, "var/db/apk/", 11) == 0) {
|
} else if (strncmp(ae->name, "var/db/apk/", 11) == 0) {
|
||||||
/* APK 1.0 format */
|
/* APK 1.0 format */
|
||||||
if (!S_ISREG(ae->mode))
|
if (!S_ISREG(ae->mode))
|
||||||
|
|
Loading…
Reference in New Issue