You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:30:03 UTC
[buildstream] 05/32: _artifactcache/*.py: Reintroduce remove()
This is an automated email from the ASF dual-hosted git repository.
root pushed a commit to branch testing/local-cache-expiry
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit c292dfb3c9c3781b702d8094330a77af61ee0f41
Author: Tristan Maat <tm...@tlater.net>
AuthorDate: Fri Mar 23 17:26:52 2018 +0000
_artifactcache/*.py: Reintroduce remove()
---
buildstream/_artifactcache/artifactcache.py | 14 ++++++++++++++
buildstream/_artifactcache/ostreecache.py | 3 +++
buildstream/_artifactcache/tarcache.py | 10 ++++++++++
3 files changed, 27 insertions(+)
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index 2d745f8..e9611bf 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -191,6 +191,20 @@ class ArtifactCache():
raise ImplError("Cache '{kind}' does not implement contains()"
.format(kind=type(self).__name__))
+ # remove():
+ #
+ # Removes the artifact for the specified ref from the local
+ # artifact cache.
+ #
+ # Args:
+ # ref (artifact_name): The name of the artifact to remove (as
+ # generated by
+ # `ArtifactCache.get_artifact_fullname`)
+ #
+ def remove(self, artifact_name):
+ raise ImplError("Cache '{kind}' does not implement remove()"
+ .format(kind=type(self).__name__))
+
# extract():
#
# Extract cached artifact for the specified Element if it hasn't
diff --git a/buildstream/_artifactcache/ostreecache.py b/buildstream/_artifactcache/ostreecache.py
index 707a974..f71bee0 100644
--- a/buildstream/_artifactcache/ostreecache.py
+++ b/buildstream/_artifactcache/ostreecache.py
@@ -90,6 +90,9 @@ class OSTreeCache(ArtifactCache):
ref = self.get_artifact_fullname(element, key)
return _ostree.exists(self.repo, ref)
+ def remove(self, ref):
+ return _ostree.remove(self.repo, ref)
+
def extract(self, element, key):
ref = self.get_artifact_fullname(element, key)
diff --git a/buildstream/_artifactcache/tarcache.py b/buildstream/_artifactcache/tarcache.py
index ab814ab..d995929 100644
--- a/buildstream/_artifactcache/tarcache.py
+++ b/buildstream/_artifactcache/tarcache.py
@@ -44,6 +44,16 @@ class TarCache(ArtifactCache):
path = os.path.join(self.tardir, _tarpath(element, key))
return os.path.isfile(path)
+ # remove()
+ #
+ # Implements artifactcache.remove().
+ #
+ def remove(self, artifact_name):
+ artifact = os.path.join(self.tardir, artifact_name + '.tar.bz2')
+ size = os.stat(artifact, follow_symlinks=False).st_size
+ os.remove(artifact)
+ return size
+
def commit(self, element, content, keys):
os.makedirs(os.path.join(self.tardir, element._get_project().name, element.normal_name), exist_ok=True)