From 9177f77e695f03d35c93b9e531a834fa379b485f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 30 Jan 2018 15:47:51 +0100 Subject: [PATCH] Link refresh: gracefully handle case where 'file_path' is not set. In this case an error is logged and the entire link regeneration is aborted. In other words, variations aren't refreshed either. --- pillar/api/file_storage/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pillar/api/file_storage/__init__.py b/pillar/api/file_storage/__init__.py index 4fe17087..e8e18c54 100644 --- a/pillar/api/file_storage/__init__.py +++ b/pillar/api/file_storage/__init__.py @@ -447,7 +447,14 @@ def generate_all_links(response, now): response['project']) if 'project' in response else None # TODO: add project id to all files backend = response['backend'] - response['link'] = generate_link(backend, response['file_path'], project_id) + + if 'file_path' in response: + response['link'] = generate_link(backend, response['file_path'], project_id) + else: + import pprint + log.error('File without file_path properly, unable to generate links: %s', + pprint.pformat(response)) + return variations = response.get('variations') if variations: