summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-04-18 18:00:30 +0100
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-04-18 18:00:30 +0100
commitd751e8da557741eb21d0856293e80d57474721b7 (patch)
tree84f3851da4cbb423e0607f20298c797909cf94bd
parenta58f373cec3b3bd4420478c99dde6e7fa2cba31b (diff)
downloadmorph-cache-server-d751e8da557741eb21d0856293e80d57474721b7.tar.gz
Add support for /artifacts.
-rwxr-xr-xmorph-cache-server17
1 files changed, 17 insertions, 0 deletions
diff --git a/morph-cache-server b/morph-cache-server
index 57713e2..4639a33 100755
--- a/morph-cache-server
+++ b/morph-cache-server
@@ -29,6 +29,7 @@ from morphcacheserver.repocache import RepoCache
defaults = {
'repo-dir': '/var/cache/morph-cache-server/gits',
'bundle-dir': '/var/cache/morph-cache-server/bundles',
+ 'artifact-dir': '/var/cache/morph-cache-server/artifacts',
}
@@ -43,6 +44,10 @@ class MorphCacheServer(cliapp.Application):
'path to the bundle cache directory',
metavar='PATH',
default=defaults['bundle-dir'])
+ self.settings.string(['artifact-dir'],
+ 'path to the artifact cache directory',
+ metavar='PATH',
+ default=defaults['artifact-dir'])
def process_args(self, args):
app = Bottle()
@@ -87,6 +92,18 @@ class MorphCacheServer(cliapp.Application):
dirname = os.path.dirname(filename)
basename = os.path.basename(filename)
return static_file(basename, root=dirname, download=True)
+
+ @app.get('/artifacts')
+ def artifact():
+ basename = self._unescape_parameter(request.query.filename)
+ filename = os.path.join(self.settings['artifact-dir'], basename)
+ if os.path.exists(filename):
+ return static_file(basename,
+ root=self.settings['artifact-dir'],
+ download=True)
+ else:
+ response.status = 404
+ logging.debug('artifact %s does not exist' % basename)
root = Bottle()
root.mount(app, '/1.0')