Fix incomplete read from the remote side.

This commit is contained in:
Manuel Amador (Rudd-O) 2022-08-21 01:31:24 +00:00
parent 3ad3761f2f
commit 6918df4f62

View File

@ -138,16 +138,20 @@ def put(out_path):
chunksize = int(sys.stdin.readline(16))
if chunksize == 0:
break
chunk = sys.stdin.read(chunksize)
assert len(chunk) == chunksize, ("Mismatch in chunk length", len(chunk), chunksize)
try:
f.write(chunk)
sys.stdout.write(b'Y\n')
except (IOError, OSError) as e:
sys.stdout.write(b'N\n')
encode_exception(e, sys.stdout)
f.close()
return
while True:
chunk = sys.stdin.read(chunksize)
if chunk == b"":
assert chunksize == 0, "Never could finish reading the last %s bytes" % chunksize
break
try:
f.write(chunk)
except (IOError, OSError) as e:
sys.stdout.write(b'N\n')
encode_exception(e, sys.stdout)
f.close()
return
chunksize = chunksize - len(chunk)
sys.stdout.write(b'Y\n')
try:
f.flush()
except (IOError, OSError) as e: