Fix bloody Eve raising exceptions instead of returning status code
This commit is contained in:
@@ -71,14 +71,19 @@ def before_delete_project(document):
|
|||||||
|
|
||||||
def after_delete_project(project: dict):
|
def after_delete_project(project: dict):
|
||||||
"""Perform delete on the project's files too."""
|
"""Perform delete on the project's files too."""
|
||||||
|
from werkzeug.exceptions import NotFound
|
||||||
from eve.methods.delete import delete
|
from eve.methods.delete import delete
|
||||||
|
|
||||||
pid = project['_id']
|
pid = project['_id']
|
||||||
log.info('Project %s was deleted, also deleting its files.', pid)
|
log.info('Project %s was deleted, also deleting its files.', pid)
|
||||||
|
|
||||||
|
try:
|
||||||
r, _, _, status = delete('files', {'project': pid})
|
r, _, _, status = delete('files', {'project': pid})
|
||||||
|
except NotFound:
|
||||||
|
# There were no files, and that's fine.
|
||||||
|
return
|
||||||
if status != 204:
|
if status != 204:
|
||||||
|
# Will never happen because bloody Eve always returns 204 or raises an exception.
|
||||||
log.warning('Unable to delete files of project %s: %s', pid, r)
|
log.warning('Unable to delete files of project %s: %s', pid, r)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user