Commit bb918e49 authored by aberent@chromium.org's avatar aberent@chromium.org

Make PushIfNeeded do what is says.

PushIfNeeded was pushing unconditionally when either the source or destination directory included a symbolic link it its path. This CL fixes that.

NOTRY=True
BUG=314578

Review URL: https://codereview.chromium.org/57633003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233387 0039d316-1c4b-4281-b951-d872f2087c98
parent e16968e9
...@@ -841,13 +841,21 @@ class AndroidCommands(object): ...@@ -841,13 +841,21 @@ class AndroidCommands(object):
A list of tuples of the form (host_path, device_path) for files whose A list of tuples of the form (host_path, device_path) for files whose
md5sums do not match. md5sums do not match.
""" """
# Md5Sum resolves symbolic links in path names so the calculation of
# relative path names from its output will need the real path names of the
# base directories. Having calculated these they are used throughout the
# function since this makes us less subject to any future changes to Md5Sum.
real_host_path = os.path.realpath(host_path)
real_device_path = self.RunShellCommand('realpath "%s"' % device_path)[0]
host_hash_tuples, device_hash_tuples = self._RunMd5Sum( host_hash_tuples, device_hash_tuples = self._RunMd5Sum(
host_path, device_path) real_host_path, real_device_path)
# Ignore extra files on the device. # Ignore extra files on the device.
if not ignore_filenames: if not ignore_filenames:
host_files = [os.path.relpath(os.path.normpath(p.path), host_files = [os.path.relpath(os.path.normpath(p.path),
os.path.normpath(host_path)) for p in host_hash_tuples] real_host_path) for p in host_hash_tuples]
def HostHas(fname): def HostHas(fname):
return any(path in fname for path in host_files) return any(path in fname for path in host_files)
...@@ -862,12 +870,12 @@ class AndroidCommands(object): ...@@ -862,12 +870,12 @@ class AndroidCommands(object):
# only a single file is given as the base name given in device_path may # only a single file is given as the base name given in device_path may
# differ from that in host_path. # differ from that in host_path.
def HostToDevicePath(host_file_path): def HostToDevicePath(host_file_path):
return os.path.join(device_path, os.path.relpath( return os.path.join(device_path, os.path.relpath(host_file_path,
host_file_path, os.path.normpath(host_path))) real_host_path))
device_hashes = [h.hash for h in device_hash_tuples] device_hashes = [h.hash for h in device_hash_tuples]
return [(t.path, HostToDevicePath(t.path) if os.path.isdir(host_path) else return [(t.path, HostToDevicePath(t.path) if
device_path) os.path.isdir(real_host_path) else real_device_path)
for t in host_hash_tuples if t.hash not in device_hashes] for t in host_hash_tuples if t.hash not in device_hashes]
def PushIfNeeded(self, host_path, device_path): def PushIfNeeded(self, host_path, device_path):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment