OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Provides a variety of device interactions based on adb. | 5 """Provides a variety of device interactions based on adb. |
6 | 6 |
7 Eventually, this will be based on adb_wrapper. | 7 Eventually, this will be based on adb_wrapper. |
8 """ | 8 """ |
9 # pylint: disable=unused-argument | 9 # pylint: disable=unused-argument |
10 | 10 |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 def _GetChangedFilesImpl(self, host_path, device_path): | 847 def _GetChangedFilesImpl(self, host_path, device_path): |
848 real_host_path = os.path.realpath(host_path) | 848 real_host_path = os.path.realpath(host_path) |
849 try: | 849 try: |
850 real_device_path = self.RunShellCommand( | 850 real_device_path = self.RunShellCommand( |
851 ['realpath', device_path], single_line=True, check_return=True) | 851 ['realpath', device_path], single_line=True, check_return=True) |
852 except device_errors.CommandFailedError: | 852 except device_errors.CommandFailedError: |
853 real_device_path = None | 853 real_device_path = None |
854 if not real_device_path: | 854 if not real_device_path: |
855 return [(host_path, device_path)] | 855 return [(host_path, device_path)] |
856 | 856 |
857 host_hash_tuples = md5sum.CalculateHostMd5Sums([real_host_path]) | 857 host_checksums = md5sum.CalculateHostMd5Sums([real_host_path]) |
858 device_paths_to_md5 = ( | 858 device_paths_to_md5 = ( |
859 real_device_path if os.path.isfile(real_host_path) | 859 real_device_path if os.path.isfile(real_host_path) |
860 else ('%s/%s' % (real_device_path, os.path.relpath(p, real_host_path)) | 860 else ('%s/%s' % (real_device_path, os.path.relpath(p, real_host_path)) |
861 for _, p in host_hash_tuples)) | 861 for p in host_checksums.iterkeys())) |
862 device_hash_tuples = md5sum.CalculateDeviceMd5Sums( | 862 device_checksums = md5sum.CalculateDeviceMd5Sums( |
863 device_paths_to_md5, self) | 863 device_paths_to_md5, self) |
864 | 864 |
865 if os.path.isfile(host_path): | 865 if os.path.isfile(host_path): |
866 if (not device_hash_tuples | 866 host_checksum = host_checksums.get(real_host_path) |
867 or device_hash_tuples[0].hash != host_hash_tuples[0].hash): | 867 device_checksum = device_checksums.get(real_device_path) |
| 868 if host_checksum != device_checksum: |
868 return [(host_path, device_path)] | 869 return [(host_path, device_path)] |
869 else: | 870 else: |
870 return [] | 871 return [] |
871 else: | 872 else: |
872 device_tuple_dict = dict((d.path, d.hash) for d in device_hash_tuples) | |
873 to_push = [] | 873 to_push = [] |
874 for host_hash, host_abs_path in ( | 874 for host_abs_path, host_checksum in host_checksums.iteritems(): |
875 (h.hash, h.path) for h in host_hash_tuples): | |
876 device_abs_path = '%s/%s' % ( | 875 device_abs_path = '%s/%s' % ( |
877 real_device_path, os.path.relpath(host_abs_path, real_host_path)) | 876 real_device_path, os.path.relpath(host_abs_path, real_host_path)) |
878 if (device_abs_path not in device_tuple_dict | 877 if (device_checksums.get(device_abs_path) != host_checksum): |
879 or device_tuple_dict[device_abs_path] != host_hash): | |
880 to_push.append((host_abs_path, device_abs_path)) | 878 to_push.append((host_abs_path, device_abs_path)) |
881 return to_push | 879 return to_push |
882 | 880 |
883 def _InstallCommands(self): | 881 def _InstallCommands(self): |
884 if self._commands_installed is None: | 882 if self._commands_installed is None: |
885 try: | 883 try: |
886 if not install_commands.Installed(self): | 884 if not install_commands.Installed(self): |
887 install_commands.InstallCommands(self) | 885 install_commands.InstallCommands(self) |
888 self._commands_installed = True | 886 self._commands_installed = True |
889 except Exception as e: | 887 except Exception as e: |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1575 """Returns client cache.""" | 1573 """Returns client cache.""" |
1576 if client_name not in self._client_caches: | 1574 if client_name not in self._client_caches: |
1577 self._client_caches[client_name] = {} | 1575 self._client_caches[client_name] = {} |
1578 return self._client_caches[client_name] | 1576 return self._client_caches[client_name] |
1579 | 1577 |
1580 def _ClearCache(self): | 1578 def _ClearCache(self): |
1581 """Clears all caches.""" | 1579 """Clears all caches.""" |
1582 for client in self._client_caches: | 1580 for client in self._client_caches: |
1583 self._client_caches[client].clear() | 1581 self._client_caches[client].clear() |
1584 self._cache.clear() | 1582 self._cache.clear() |
OLD | NEW |