summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmorph-cache-server21
1 files changed, 19 insertions, 2 deletions
diff --git a/morph-cache-server b/morph-cache-server
index dbf6785..c9d6662 100755
--- a/morph-cache-server
+++ b/morph-cache-server
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright (C) 2013 Codethink Limited
+# Copyright (C) 2013, 2014 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@ import logging
import os
import urllib
import urllib2
+import urlparse
import shutil
from bottle import Bottle, request, response, run, static_file
@@ -303,7 +304,23 @@ class MorphCacheServer(cliapp.Application):
else:
response.status = 404
logging.debug('artifact %s does not exist' % basename)
-
+
+ @app.post('/artifacts')
+ def post_artifacts():
+ artifacts = request.json
+ results = {}
+
+ logging.debug('Received a POST request for /artifacts')
+
+ for artifact in artifacts:
+ filename = os.path.join(self.settings['artifact-dir'], artifact)
+ results[artifact] = os.path.exists(filename)
+
+ logging.debug('%s is%s in the cache' %
+ (artifact, '' if results[artifact] else "n't"))
+
+ return results
+
root = Bottle()
root.mount(app, '/1.0')