mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-08 09:41:35 +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',
|
||||
json.dumps(results, cls=CheckJSONEncoder))
|
||||
|
||||
issue_count = 0
|
||||
severity = 'warning'
|
||||
for _app_id, app_data in results.items():
|
||||
if app_data['exception']:
|
||||
issue_count += 1
|
||||
severity = 'error'
|
||||
else:
|
||||
for check in app_data['diagnosis']:
|
||||
if check.result != Result.PASSED:
|
||||
if check.result != Result.WARNING:
|
||||
severity = 'error'
|
||||
|
||||
issue_count += 1
|
||||
issue_count = 0
|
||||
severity = 'warning'
|
||||
for _app_id, app_data in results.items():
|
||||
if app_data['exception']:
|
||||
issue_count += 1
|
||||
severity = 'error'
|
||||
else:
|
||||
for check in app_data['diagnosis']:
|
||||
if check.result != Result.PASSED:
|
||||
issue_count += 1
|
||||
if check.result != Result.WARNING:
|
||||
severity = 'error'
|
||||
|
||||
if not issue_count:
|
||||
# Remove any previous notifications if there are no issues.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user