From 5870c3581ac10c14d68337fc875000ead522e99d Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 7 Sep 2012 13:23:51 +0100 Subject: 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. --- morph-cache-server | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/morph-cache-server b/morph-cache-server index 286e56d..b4f8fa1 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) -- cgit v1.2.1