From 11684b6fd7d1cc8d501070ef84899ae93f22ff94 Mon Sep 17 00:00:00 2001 From: "Phyks (Lucas Verney)" Date: Thu, 17 Jan 2019 09:16:04 +0100 Subject: [PATCH] Don't crash metadata API route if timestamp file is not ready --- flatisfy/web/routes/api.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/flatisfy/web/routes/api.py b/flatisfy/web/routes/api.py index ca897fc..b7f8322 100644 --- a/flatisfy/web/routes/api.py +++ b/flatisfy/web/routes/api.py @@ -521,14 +521,19 @@ def metadata_v1(config): return {} try: - ts_file = os.path.join( - config['data_directory'], - 'timestamp' - ) - ts = os.path.getmtime(ts_file) + last_update = None + try: + ts_file = os.path.join( + config['data_directory'], + 'timestamp' + ) + last_update = os.path.getmtime(ts_file) + except OSError: + pass + return { 'data': { - 'last_update': ts + 'last_update': last_update } } except Exception as exc: # pylint: disable= broad-except