receiving (test mode)

This commit is contained in:
ingvar1995 2016-03-17 18:55:18 +03:00
parent 4ce7f6c6a5
commit 90cabe1a45
3 changed files with 15 additions and 10 deletions

View file

@ -35,13 +35,13 @@ class ReceiveTransfer(FileTransfer):
self._file = open(self._path, 'wb')
def write_chunk(self, position, data):
size = getsize(self._path)
if size < position + len(data):
self._file.write('\0' * (position + len(data) - size))
if data is not None:
size = getsize(self._path)
if size < position:
self._file.seek(0, 2)
self._file.write('\0' * (position - size))
self._file.seek(position)
self._file.write(data)
self._file.write(''.join(chr(x) for x in data))
self._file.flush()
else:
self._file.seek(position)
self._file.write(data)
self._file.flush()
self._file.close()