Make LocalDownloader play well with MultiArtifact.
CL:751790 added support for artifacts that involve downloading multiple
files, but LocalDownloader was not updated to support it. FixIt.
BUG=chromium:779870
BUG=chromium:799724
TEST=quick-provision artifacts are staged correctly in moblab-vm.
Change-Id: I5f93db6d4371839f4def36a1bdc670df3fe6ee44
Reviewed-on: https://chromium-review.googlesource.com/912777
Commit-Ready: Prathmesh Prabhu <pprabhu@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: David Riley <davidriley@chromium.org>
Reviewed-by: Congbin Guo <guocb@chromium.org>
diff --git a/downloader.py b/downloader.py
index f7e830f..886f651 100755
--- a/downloader.py
+++ b/downloader.py
@@ -391,17 +391,19 @@
Raises:
ArtifactDownloadError: An error occurred when obtaining artifact.
"""
- local_path = os.path.join(self.source_path, name)
if is_regex_name:
filter_re = re.compile(name)
- for filename in os.listdir(self.source_path):
- if filter_re.match(filename):
- return [filename]
+ artifacts = [f for f in os.listdir(self.source_path) if
+ filter_re.match(f)]
else:
- glob_search = glob.glob(local_path)
- if glob_search and len(glob_search) == 1:
- return [os.path.basename(glob_search[0])]
- raise build_artifact.ArtifactDownloadError('Artifact not found.')
+ glob_search = glob.glob(os.path.join(self.source_path, name))
+ artifacts = [os.path.basename(g) for g in glob_search]
+
+ if not artifacts:
+ raise build_artifact.ArtifactDownloadError(
+ 'Artifact %s not found at %s(regex_match: %s)'
+ % (name, self.source_path, is_regex_name))
+ return artifacts
def Fetch(self, remote_name, local_path):
"""Downloads artifact from Google Storage to a local directory."""