summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-10-09 17:24:36 +0100
committerBenjamin Schubert <contact@benschubert.me>2019-10-10 11:29:43 +0100
commit06d781ccdf440973f9994b3ede76debf5b7f5325 (patch)
tree16745f3133ea4c7ef0a7e57c48e48ef62814480b
parent07ee8562208bcecc2f8a12046e642b8d0e8bac5b (diff)
downloadbuildstream-bschubert/unify-caches.tar.gz
_basecache.py: Move 'update_mtime' to base classbschubert/unify-caches
Consolidate the 'update_mtime' from _artifactcache.py and _sourcecache.py.
-rw-r--r--src/buildstream/_artifactcache.py6
-rw-r--r--src/buildstream/_basecache.py6
-rw-r--r--src/buildstream/_sourcecache.py6
3 files changed, 6 insertions, 12 deletions
diff --git a/src/buildstream/_artifactcache.py b/src/buildstream/_artifactcache.py
index 538f6e102..032f8c17d 100644
--- a/src/buildstream/_artifactcache.py
+++ b/src/buildstream/_artifactcache.py
@@ -142,12 +142,6 @@ class ArtifactCache(BaseCache):
def __init__(self, context):
super().__init__(context, context.artifactdir)
- def update_mtime(self, ref):
- try:
- os.utime(os.path.join(self.refdir, ref))
- except FileNotFoundError as e:
- raise ArtifactError("Couldn't find artifact: {}".format(ref)) from e
-
# preflight():
#
# Preflight check.
diff --git a/src/buildstream/_basecache.py b/src/buildstream/_basecache.py
index 3654926a1..cec4dcd0d 100644
--- a/src/buildstream/_basecache.py
+++ b/src/buildstream/_basecache.py
@@ -263,6 +263,12 @@ class BaseCache():
return (any(remote.spec.push for remote in index_remotes) and
any(remote.spec.push for remote in storage_remotes))
+ def update_mtime(self, ref):
+ try:
+ os.utime(os.path.join(self.refdir, ref))
+ except FileNotFoundError as e:
+ raise self.spec_error("Couldn't find ref: {}".format(ref)) from e
+
################################################
# Local Private Methods #
################################################
diff --git a/src/buildstream/_sourcecache.py b/src/buildstream/_sourcecache.py
index 5105be410..16f8ad409 100644
--- a/src/buildstream/_sourcecache.py
+++ b/src/buildstream/_sourcecache.py
@@ -344,12 +344,6 @@ class SourceCache(BaseCache):
yield source.files
- def _update_mtime(self, ref):
- try:
- os.utime(self._source_path(ref))
- except FileNotFoundError as e:
- raise SourceCacheError("Couldn't find source: {}".format(ref)) from e
-
def _pull_source(self, source_ref, remote):
try:
remote.init()