summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-09-04 17:57:55 -0400
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-09-05 01:58:25 -0400
commitc586dd5a8028cf756d4896afdd27218bf25f6cb7 (patch)
tree09d1193aa7f0ee1d24510314a93d3ba75820b336
parent6e6fc965665b2cbfc5bc23a422fd45e6a9a89c5e (diff)
downloadbuildstream-c586dd5a8028cf756d4896afdd27218bf25f6cb7.tar.gz
artifactcache.py: Special casing local pull & push
It's interesting to keep the local directory push & pull codepaths alive for the sake of testing everything that calls into the artifact cache. For this reason, even when the artifact cache is "offline", it should be possible to pull and push to it if it is a local artifact share.
-rw-r--r--buildstream/_artifactcache/artifactcache.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index 3abecb103..4e2e5312f 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -63,7 +63,19 @@ class ArtifactCache():
self.extractdir = os.path.join(context.artifactdir, 'extract')
self.repo = _ostree.ensure(ostreedir, False)
+ self.__pull_local = False
+ self.__push_local = False
+
+ if self.context.artifact_push:
+ if self.context.artifact_push.startswith("/") or \
+ self.context.artifact_push.startswith("file://"):
+ self.__push_local = True
+
if self.context.artifact_pull:
+ if self.context.artifact_pull.startswith("/") or \
+ self.context.artifact_pull.startswith("file://"):
+ self.__pull_local = True
+
self.remote = utils.url_directory_name(context.artifact_pull)
_ostree.configure_remote(self.repo, self.remote, self.context.artifact_pull)
else:
@@ -241,7 +253,8 @@ class ArtifactCache():
# Returns: True if remote repository is available, False otherwise
#
def can_fetch(self):
- return not self.__offline and self.remote is not None
+ return (not self.__offline or self.__pull_local) and \
+ self.remote is not None
# pull():
#
@@ -253,7 +266,7 @@ class ArtifactCache():
#
def pull(self, element, progress=None):
- if self.__offline:
+ if self.__offline and not self.__pull_local:
raise _ArtifactError("Attempt to pull artifact while offline")
if self.context.artifact_pull.startswith("/"):
@@ -334,7 +347,8 @@ class ArtifactCache():
# Returns: True if remote repository is available, False otherwise
#
def can_push(self):
- return not self.__offline and self.context.artifact_push is not None
+ return (not self.__offline or self.__push_local) and \
+ self.context.artifact_push is not None
# push():
#
@@ -351,7 +365,7 @@ class ArtifactCache():
# _ArtifactError if there was an error
def push(self, element):
- if self.__offline:
+ if self.__offline and not self.__push_local:
raise _ArtifactError("Attempt to push artifact while offline")
if self.context.artifact_push is None: