Skip to content

Commit f7beccd

Browse files
committed
Create last_exec file after creating dirs, throw 500 if errors on access
1 parent bc8b6bd commit f7beccd

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

src/server/Dockerfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ RUN pip install --no-cache-dir -r /requirements.txt
1515
COPY . .
1616

1717
RUN mkdir /app/static \
18-
/app/static/raw_data \
19-
/app/static/raw_data/current \
20-
/app/static/output \
21-
/app/static/output/reports \
22-
/app/static/logs \
23-
/app/static/zipped
18+
/app/static/raw_data \
19+
/app/static/raw_data/current \
20+
/app/static/output \
21+
/app/static/output/reports \
22+
/app/static/logs \
23+
/app/static/zipped
24+
25+
RUN [ ! -f /app/static/logs/last_execution.json ] && printf null > /app/static/logs/last_execution.json
2426

2527
RUN chmod -R 777 /app/static
2628

src/server/api/admin_api.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,19 @@ def listStatistics():
118118
last_execution_details = json.loads(last_execution_file.read())
119119
last_execution_file.close()
120120

121+
except (FileNotFoundError):
122+
current_app.logger.error("last_execution.json file was missing")
123+
return abort(500)
124+
125+
except (json.JSONDecodeError):
126+
current_app.logger.error(
127+
"last_execution.json could not be decoded - possible corruption"
128+
)
129+
return abort(500)
130+
121131
except Exception as e:
122-
return jsonify(None)
132+
current_app.logger.error("Failure reading last_execution.json: ", e)
133+
return abort(500)
123134

124135
return jsonify(last_execution_details)
125136

0 commit comments

Comments
 (0)