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

Fix issue where attempting to download a binary file fails #163

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions adb/fastboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,13 @@ def Download(self, source_file, source_len=0,
"""
if isinstance(source_file, str):
source_len = os.stat(source_file).st_size
source_file = open(source_file)
source_file = open(source_file, "rb")

with source_file:
if source_len == 0:
# Fall back to storing it all in memory :(
data = source_file.read()
source_file = io.BytesIO(data.encode('utf8'))
source_file = io.BytesIO(data if isinstance(data, bytes) else data.encode("utf-8"))
source_len = len(data)

self._protocol.SendCommand(b'download', b'%08x' % source_len)
Expand Down