mirror of
https://github.com/pygos/pkg-utils.git
synced 2024-11-22 04:49:46 +01:00
pkg reader: try to read *entire* requested chunk
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
parent
aa6bbf2ef4
commit
c78dc2255f
1 changed files with 20 additions and 14 deletions
|
@ -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 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)
|
if (rd->have_error)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (rd->have_eof || rd->offset_raw == rd->current.raw_size)
|
if (rd->have_eof || rd->offset_raw == rd->current.raw_size)
|
||||||
return 0;
|
break;
|
||||||
|
|
||||||
if (prefetch_compressed(rd))
|
if (prefetch_compressed(rd))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -254,7 +255,12 @@ ssize_t pkg_reader_read_payload(pkg_reader_t *rd, void *out, size_t size)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
rd->offset_raw += ret;
|
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)
|
int pkg_reader_rewind(pkg_reader_t *rd)
|
||||||
|
|
Loading…
Reference in a new issue