1
0
Fork 0
mirror of https://github.com/pygos/pkg-utils.git synced 2024-11-21 20:39:46 +01:00

pkg reader: try to read *entire* requested chunk

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
David Oberhollenzer 2019-04-09 16:02:22 +02:00
parent aa6bbf2ef4
commit c78dc2255f

View file

@ -235,13 +235,14 @@ record_t *pkg_reader_current_record_header(pkg_reader_t *rd)
ssize_t pkg_reader_read_payload(pkg_reader_t *rd, void *out, size_t size)
{
ssize_t ret;
ssize_t ret, total = 0;
do {
if (rd->have_error)
return -1;
if (rd->have_eof || rd->offset_raw == rd->current.raw_size)
return 0;
break;
if (prefetch_compressed(rd))
return -1;
@ -254,7 +255,12 @@ ssize_t pkg_reader_read_payload(pkg_reader_t *rd, void *out, size_t size)
return -1;
rd->offset_raw += ret;
return ret;
out = (char *)out + ret;
size -= ret;
total += ret;
} while (size > 0);
return total;
}
int pkg_reader_rewind(pkg_reader_t *rd)