This commit is contained in:
2020-08-29 14:00:37 +02:00
parent e27318f49d
commit f34d1a1a38

View File

@@ -487,22 +487,22 @@ class NetFH(Thread):
HEADER_START, b'DA', self.__position, length, HEADER_STOP HEADER_START, b'DA', self.__position, length, HEADER_STOP
)) ))
self.__position += length net_buffer = b''
buffer.clear()
while length > 0: while length > 0:
count = self._slavesock.recv_into( count = self._slavesock.recv_into(
self.__buff_block, self.__buff_block,
min(length, self.__buff_size), min(length, self.__buff_size),
) )
if count == 0: if count == 0:
# Add missing bytes with zero to restore original size
buffer += bytearray(length)
self.__sockerr.set() self.__sockerr.set()
raise IOError("read error on network") raise IOError("read error on network")
buffer += self.__buff_block[:count] net_buffer += self.__buff_block[:count]
length -= count length -= count
# We received the correct amount of bytes here
self.__position += length
buffer[:] = net_buffer
return len(buffer) return len(buffer)
def readpictory(self) -> bytes: def readpictory(self) -> bytes: