summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/io.c b/src/io.c
index c14cc23..667d9aa 100644
--- a/src/io.c
+++ b/src/io.c
@@ -138,7 +138,7 @@ size_t apk_istream_splice(void *stream, int fd, size_t size,
bufsz = size;
if (size > 128 * 1024) {
- if (ftruncate(fd, size) == 0)
+ if (size != APK_SPLICE_ALL && ftruncate(fd, size) == 0)
mmapbase = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
if (bufsz > 2*1024*1024)
@@ -165,6 +165,8 @@ size_t apk_istream_splice(void *stream, int fd, size_t size,
r = is->read(is, buf, togo);
if (r < 0)
goto err;
+ if (r == 0)
+ break;
if (mmapbase == MAP_FAILED) {
if (write(fd, buf, r) != r) {