Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 43ee205

Browse files
committed
length fix for stringio
1 parent e1db3c2 commit 43ee205

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

adb/fastboot.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,13 @@ def Download(self, source_file, source_len=0,
328328
with open(source_file_path, 'rb') as fh:
329329
source_file = BytesIO(fh.read())
330330

331-
elif isinstance(source_file, StringIO):
332-
source_file = BytesIO(source_file.read())
333-
334331
if not source_len:
335-
source_len = len(source_file)
332+
if isinstance(source_file, StringIO):
333+
source_file.seek(0, os.SEEK_END)
334+
source_len = source_file.tell()
335+
source_file.seek(0)
336+
else:
337+
source_len = len(source_file)
336338

337339
self._protocol.SendCommand(b'download', b'%08x' % source_len)
338340
return self._protocol.HandleDataSending(

0 commit comments

Comments
 (0)