summaryrefslogtreecommitdiff
path: root/morphlib/localartifactcache.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-10-05 13:16:16 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-10-05 13:16:16 +0100
commitfac22b615d4904bc7bcaf01962bf984f65f1159c (patch)
tree8dee61ac1595bcd64baa10fcdab4a2a032a2c488 /morphlib/localartifactcache.py
parent7d6094ed068f16d6fd5a51aa201865efbc364669 (diff)
downloadmorph-fac22b615d4904bc7bcaf01962bf984f65f1159c.tar.gz
Add a way for a local artifact cache to clear itself
Diffstat (limited to 'morphlib/localartifactcache.py')
-rw-r--r--morphlib/localartifactcache.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/morphlib/localartifactcache.py b/morphlib/localartifactcache.py
index 893359d8..7ad53db0 100644
--- a/morphlib/localartifactcache.py
+++ b/morphlib/localartifactcache.py
@@ -71,3 +71,16 @@ class LocalArtifactCache(object):
def _source_metadata_filename(self, source, cachekey, name):
basename = '%s.%s' % (cachekey, name)
return os.path.join(self.cachedir, basename)
+
+ def clear(self):
+ '''Clear everything from the artifact cache directory.
+
+ After calling this, the artifact cache will be entirely empty.
+ Caveat caller.
+
+ '''
+
+ for dirname, subdirs, basenames in os.walk(self.cachedir):
+ for basename in basenames:
+ os.remove(os.path.join(dirname, basename))
+