summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-09-07 13:23:51 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-09-07 13:49:35 +0100
commit5870c3581ac10c14d68337fc875000ead522e99d (patch)
tree3301b1bfc6edc4ac90c931db33a27728e24d1dbe
parent1a0e40d854d37f81e9cdaf8bb23e480790614d2a (diff)
downloadmorph-5870c3581ac10c14d68337fc875000ead522e99d.tar.gz
Add facility to delete artifacts
In order to allow the artifact cache to be cleaned up, this patch allows for a /delete method which can remove artifacts from the cache. It takes the following arguments: artifact=artifactname The artifact will be deleted and a JSON object returned in the form: { "status": errno, "reason": strerror } Where errno is zero on success, 1 on EPERM, 2 on ENOENT etc. and reason is the strerror of the errno, in case the architectures differ between caller and cache.
-rwxr-xr-xmorph-cache-server13
1 files changed, 13 insertions, 0 deletions
diff --git a/morph-cache-server b/morph-cache-server
index 286e56db..b4f8fa1a 100755
--- a/morph-cache-server
+++ b/morph-cache-server
@@ -137,6 +137,19 @@ class MorphCacheServer(cliapp.Application):
response.status = 500
logging.debug('%s' % e)
+ @writable('/delete')
+ def delete():
+ artifact = self._unescape_parameter(request.query.artifact)
+ try:
+ os.unlink('%s/%s' % (self.settings['artifact-dir'],
+ artifact))
+ return { "status": 0, "reason": "success" }
+ except OSError, ose:
+ return { "status": ose.errno, "reason": ose.strerror }
+ except Exception, e:
+ response.status = 500
+ logging.debug('%s' % e)
+
@app.get('/sha1s')
def sha1():
repo = self._unescape_parameter(request.query.repo)