mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 19:33:18 +00:00
Bug 1135255 - Fix mozdevice tempfile handling on Windows. r=gbrown
This commit is contained in:
parent
52a087cd8d
commit
cf9936f338
@ -408,25 +408,20 @@ class DeviceManagerADB(DeviceManager):
|
||||
|
||||
def pullFile(self, remoteFile, offset=None, length=None):
|
||||
# TODO: add debug flags and allow for printing stdout
|
||||
localFile = tempfile.mkstemp()[1]
|
||||
self._runPull(remoteFile, localFile)
|
||||
|
||||
f = open(localFile, 'r')
|
||||
|
||||
# ADB pull does not support offset and length, but we can instead
|
||||
# read only the requested portion of the local file
|
||||
if offset is not None and length is not None:
|
||||
f.seek(offset)
|
||||
ret = f.read(length)
|
||||
elif offset is not None:
|
||||
f.seek(offset)
|
||||
ret = f.read()
|
||||
else:
|
||||
ret = f.read()
|
||||
|
||||
f.close()
|
||||
mozfile.remove(localFile)
|
||||
return ret
|
||||
with mozfile.NamedTemporaryFile() as tf:
|
||||
self._runPull(remoteFile, tf.name)
|
||||
# we need to reopen the file to get the written contents
|
||||
with open(tf.name) as tf2:
|
||||
# ADB pull does not support offset and length, but we can
|
||||
# instead read only the requested portion of the local file
|
||||
if offset is not None and length is not None:
|
||||
tf2.seek(offset)
|
||||
return tf2.read(length)
|
||||
elif offset is not None:
|
||||
tf2.seek(offset)
|
||||
return tf2.read()
|
||||
else:
|
||||
return tf2.read()
|
||||
|
||||
def getFile(self, remoteFile, localFile):
|
||||
self._runPull(remoteFile, localFile)
|
||||
@ -445,16 +440,10 @@ class DeviceManagerADB(DeviceManager):
|
||||
"""
|
||||
Return the md5 sum of a file on the device
|
||||
"""
|
||||
localFile = tempfile.mkstemp()[1]
|
||||
localFile = self._runPull(remoteFile, localFile)
|
||||
with tempfile.NamedTemporaryFile() as f:
|
||||
self._runPull(remoteFile, f.name)
|
||||
|
||||
if localFile is None:
|
||||
return None
|
||||
|
||||
md5 = self._getLocalHash(localFile)
|
||||
mozfile.remove(localFile)
|
||||
|
||||
return md5
|
||||
return self._getLocalHash(f.name)
|
||||
|
||||
def _setupDeviceRoot(self, deviceRoot):
|
||||
# user-specified device root, create it and return it
|
||||
|
Loading…
Reference in New Issue
Block a user