From fac22b615d4904bc7bcaf01962bf984f65f1159c Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 5 Oct 2012 13:16:16 +0100 Subject: Add a way for a local artifact cache to clear itself --- morphlib/localartifactcache.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'morphlib/localartifactcache.py') 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)) + -- cgit v1.2.1