diff options
author | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-10-02 14:49:44 +0100 |
---|---|---|
committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-10-02 14:49:44 +0100 |
commit | 53e1b30f654d05a26a999a0ad7b8ff9c1895aef6 (patch) | |
tree | b4aeb64aad86318ea77ba7a36a550bbb3c9c845f | |
parent | 963dca9868938241740d63ec1475c5f887513e0c (diff) | |
parent | ac0c001c814d25c09d9a60b2fa6fc76e3f611181 (diff) | |
download | morph-53e1b30f654d05a26a999a0ad7b8ff9c1895aef6.tar.gz |
Merge branch 'baserock/pedroalvarez/fix-xfer-hole'
Reviewed-by: Pedro Alvarez
Reviewed-by: Paul Sherwood
-rwxr-xr-x | morphlib/xfer-hole | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/morphlib/xfer-hole b/morphlib/xfer-hole index 0d4cee7a..22ee06bf 100755 --- a/morphlib/xfer-hole +++ b/morphlib/xfer-hole @@ -120,8 +120,14 @@ def make_xfer_instructions(fd): def copy_slice_from_file(to, fd, start, end): safe_lseek(fd, start, os.SEEK_SET) - data = os.read(fd, end - start) - to.write(data) + nbytes = end - start + max_at_a_time = 1024**2 + while nbytes > 0: + data = os.read(fd, min(nbytes, max_at_a_time)) + if not data: + break + to.write(data) + nbytes -= len(data) for kind, start, end in make_xfer_instructions(fd): |