adb: mkdir the correct directory name when pulling.

The directory name should be based off of the local path, not the remote
path.

Change-Id: I75b089b8734e9dbf8e466b1e00ea18549fd101bb
(cherry picked from commit 89ec3a8d0f)
This commit is contained in:
Josh Gao 2016-03-02 16:00:02 -08:00
parent 48bc0d7853
commit 379612b128
2 changed files with 25 additions and 1 deletions

View File

@ -813,7 +813,7 @@ static bool remote_build_list(SyncConnection& sc, std::vector<copyinfo>* file_li
std::vector<copyinfo> linklist;
// Add an entry for the current directory to ensure it gets created before pulling its contents.
copyinfo ci(adb_dirname(lpath), adb_dirname(rpath), adb_basename(rpath), S_IFDIR);
copyinfo ci(adb_dirname(lpath), adb_dirname(rpath), adb_basename(lpath), S_IFDIR);
file_list->push_back(ci);
// Put the files/dirs in rpath on the lists.

View File

@ -911,6 +911,30 @@ class FileOperationsTest(DeviceTest):
if host_dir is not None:
shutil.rmtree(host_dir)
def test_pull_dir_nonexistent(self):
"""Pull a directory of files from the device to a nonexistent path."""
try:
host_dir = tempfile.mkdtemp()
dest_dir = os.path.join(host_dir, 'dest')
self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
self.device.shell(['mkdir', '-p', self.DEVICE_TEMP_DIR])
# Populate device directory with random files.
temp_files = make_random_device_files(
self.device, in_dir=self.DEVICE_TEMP_DIR, num_files=32)
self.device.pull(remote=self.DEVICE_TEMP_DIR, local=dest_dir)
for temp_file in temp_files:
host_path = os.path.join(dest_dir, temp_file.base_name)
self._verify_local(temp_file.checksum, host_path)
self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
finally:
if host_dir is not None:
shutil.rmtree(host_dir)
def test_pull_symlink_dir(self):
"""Pull a symlink to a directory of symlinks to files."""
try: