From 06d781ccdf440973f9994b3ede76debf5b7f5325 Mon Sep 17 00:00:00 2001 From: Benjamin Schubert Date: Wed, 9 Oct 2019 17:24:36 +0100 Subject: _basecache.py: Move 'update_mtime' to base class Consolidate the 'update_mtime' from _artifactcache.py and _sourcecache.py. --- src/buildstream/_artifactcache.py | 6 ------ src/buildstream/_basecache.py | 6 ++++++ src/buildstream/_sourcecache.py | 6 ------ 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() -- cgit v1.2.1