From f34d1a1a386f27e37243dad28ef224184ac079cb Mon Sep 17 00:00:00 2001 From: Sven Sager Date: Sat, 29 Aug 2020 14:00:37 +0200 Subject: [PATCH] Restore fix c20caaa5d54ada965c464d24b6a2f95f3756e412 --- revpimodio2/netio.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/revpimodio2/netio.py b/revpimodio2/netio.py index 25da205..8b823e1 100644 --- a/revpimodio2/netio.py +++ b/revpimodio2/netio.py @@ -487,22 +487,22 @@ class NetFH(Thread): HEADER_START, b'DA', self.__position, length, HEADER_STOP )) - self.__position += length - - buffer.clear() + net_buffer = b'' while length > 0: count = self._slavesock.recv_into( self.__buff_block, min(length, self.__buff_size), ) if count == 0: - # Add missing bytes with zero to restore original size - buffer += bytearray(length) self.__sockerr.set() raise IOError("read error on network") - buffer += self.__buff_block[:count] + net_buffer += self.__buff_block[:count] length -= count + # We received the correct amount of bytes here + self.__position += length + buffer[:] = net_buffer + return len(buffer) def readpictory(self) -> bytes: