summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.co.uk>2019-09-04 16:26:33 +0100
committerJames Ennis <james.ennis@codethink.co.uk>2019-09-04 16:26:33 +0100
commit95d3334f485d5a02afa094153abc8e4dd21c3f56 (patch)
tree9f4ae9eb15c1eb8672062571db35a7967f218141
parentfa88503a6836ae93f7ebeaa8e8cccd9b82bc43fd (diff)
downloadbuildstream-95d3334f485d5a02afa094153abc8e4dd21c3f56.tar.gz
_project.py: Don't only load cached artifacts
Previously, before loading artifact refs (ArtifactElements) we were checking that they were cached before loading them. This obviously becomes a problem when we want to try and pull an artifact. This patch removes the check for cached artifacts as we should still be able to contruct an ArtifactElement regardless of whether it is cached or not.
-rw-r--r--src/buildstream/_project.py5
-rw-r--r--src/buildstream/_stream.py6
-rw-r--r--tests/frontend/buildcheckout.py2
3 files changed, 5 insertions, 8 deletions
diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py
index 00beebfab..7260d9614 100644
--- a/src/buildstream/_project.py
+++ b/src/buildstream/_project.py
@@ -482,13 +482,8 @@ class Project():
# 2. The ArtifactCache.contains() method expects an Element
# and a key, not a ref.
#
- artifactdir = self._context.artifactdir
artifacts = []
for ref in targets:
- if not os.path.exists(os.path.join(artifactdir, ref)):
- raise LoadError("{}\nis not present in the artifact cache ({})".format(ref, artifactdir),
- LoadErrorReason.MISSING_FILE)
-
artifacts.append(ArtifactElement._new_from_artifact_ref(ref, self._context, task))
ArtifactElement._clear_artifact_refs_cache()
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index 5d5c355b1..083dc1c43 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -414,7 +414,8 @@ class Stream():
selection=selection,
ignore_junction_targets=ignore_junction_targets,
use_artifact_config=use_config,
- artifact_remote_url=remote)
+ artifact_remote_url=remote,
+ load_refs=True)
if not self._artifacts.has_fetch_remotes():
raise StreamError("No artifact caches available for pulling artifacts")
@@ -559,7 +560,8 @@ class Stream():
self._export_artifact(tar, location, compression, target, hardlinks, virdir)
except AttributeError as e:
raise ArtifactError("Artifact reference '{}' seems to be invalid. "
- "Note that an Element name can also be used.".format(artifact))from e
+ "Note that an Element name can also be used."
+ .format(artifact._element.get_artifact_name())) from e
else:
try:
with target._prepare_sandbox(scope=scope, directory=None,
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index 98b179b9e..6281217b7 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -358,7 +358,7 @@ def test_build_checkout_invalid_ref(datafiles, cli):
checkout_args = ['artifact', 'checkout', '--deps', 'none', '--tar', checkout, non_existent_artifact]
result = cli.run(project=project, args=checkout_args)
- assert "{}\nis not present in the artifact cache".format(non_existent_artifact) in result.stderr
+ assert "Artifact reference '{}' seems to be invalid".format(non_existent_artifact) in result.stderr
@pytest.mark.datafiles(DATA_DIR)