mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
diagnostics: Safely access results when showing notification
It is best to have obtained the results lock when counting the severe failures in diagnostic results. Tests: - When some packages are outdated, notification is shown with warning severity. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
5f08752058
commit
ba145b3194
@ -271,19 +271,18 @@ def _run_diagnostics():
|
|||||||
kvstore.set('diagnostics_results',
|
kvstore.set('diagnostics_results',
|
||||||
json.dumps(results, cls=CheckJSONEncoder))
|
json.dumps(results, cls=CheckJSONEncoder))
|
||||||
|
|
||||||
issue_count = 0
|
issue_count = 0
|
||||||
severity = 'warning'
|
severity = 'warning'
|
||||||
for _app_id, app_data in results.items():
|
for _app_id, app_data in results.items():
|
||||||
if app_data['exception']:
|
if app_data['exception']:
|
||||||
issue_count += 1
|
issue_count += 1
|
||||||
severity = 'error'
|
severity = 'error'
|
||||||
else:
|
else:
|
||||||
for check in app_data['diagnosis']:
|
for check in app_data['diagnosis']:
|
||||||
if check.result != Result.PASSED:
|
if check.result != Result.PASSED:
|
||||||
if check.result != Result.WARNING:
|
issue_count += 1
|
||||||
severity = 'error'
|
if check.result != Result.WARNING:
|
||||||
|
severity = 'error'
|
||||||
issue_count += 1
|
|
||||||
|
|
||||||
if not issue_count:
|
if not issue_count:
|
||||||
# Remove any previous notifications if there are no issues.
|
# Remove any previous notifications if there are no issues.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user