From c3e23532be14c5563b0d453ad7347ababe6c5f59 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Thu, 18 Jul 2019 14:39:38 +0200 Subject: [PATCH] [IMP] runbot: allow nginx access to tests dir In order to stores other things than logs, that could be accessible by end users, for example screenshots and screencasts, a "tests" directory is allowed thruough the nginx template in the builds directories. Also, the "with" context manager is used to open the nginx configuration to ensure that the file descriptor is released during long running crons. --- runbot/models/repo.py | 3 ++- runbot/templates/nginx.xml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/runbot/models/repo.py b/runbot/models/repo.py index 9b4b6e12..542b8753 100644 --- a/runbot/models/repo.py +++ b/runbot/models/repo.py @@ -499,7 +499,8 @@ class runbot_repo(models.Model): nginx_config = self.env['ir.ui.view'].render_template("runbot.nginx_config", settings) os.makedirs(nginx_dir, exist_ok=True) - open(os.path.join(nginx_dir, 'nginx.conf'), 'wb').write(nginx_config) + with open(os.path.join(nginx_dir, 'nginx.conf'), 'wb') as nginx_file: + nginx_file.write(nginx_config) try: _logger.debug('reload nginx') pid = int(open(os.path.join(nginx_dir, 'nginx.pid')).read().strip(' \n')) diff --git a/runbot/templates/nginx.xml b/runbot/templates/nginx.xml index d4f41f72..ac7aff22 100644 --- a/runbot/templates/nginx.xml +++ b/runbot/templates/nginx.xml @@ -39,7 +39,7 @@ server { location /runbot/static/ { alias ; autoindex off; - location ~ /runbot/static/build/[^/]+/logs/ { + location ~ /runbot/static/build/[^/]+/(logs|tests)/ { autoindex on; } }