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

Commit 82bfd52

Browse files
authored
Handle open files/filenames correctly in Pull
For #113
1 parent 5f7c295 commit 82bfd52

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

adb/adb_commands.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ def Pull(self, device_filename, dest_file=None, timeout_ms=None, progress_callba
292292
dest_file = io.BytesIO()
293293
elif isinstance(dest_file, str):
294294
dest_file = open(dest_file, 'wb')
295+
elif isinstance(dest_file, file):
296+
pass
295297
else:
296298
raise ValueError("destfile is of unknown type")
297299

@@ -305,7 +307,10 @@ def Pull(self, device_filename, dest_file=None, timeout_ms=None, progress_callba
305307
return dest_file.getvalue()
306308
else:
307309
dest_file.close()
308-
return os.path.exists(dest_file)
310+
if hasattr(dest_file, 'name'):
311+
return os.path.exists(dest_file.name)
312+
# We don't know what the path is, so we just assume it exists.
313+
return True
309314

310315
def Stat(self, device_filename):
311316
"""Get a file's stat() information."""

0 commit comments

Comments
 (0)