diff --git a/.gitignore b/.gitignore index 62b788c..e2f81da 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ coverage web/scss/.sass-cache/ api/thumbnails/ +api/logs/ build/ diff --git a/api/phenome10k/routes/files.py b/api/phenome10k/routes/files.py index 2e61e20..8939184 100644 --- a/api/phenome10k/routes/files.py +++ b/api/phenome10k/routes/files.py @@ -6,8 +6,8 @@ from flask import Blueprint, redirect, url_for, send_file from flask import Response, current_app, send_from_directory from flask import request -from flask.helpers import safe_join from werkzeug.exceptions import NotFound, BadRequest +from werkzeug.utils import safe_join from ._decorators import login_required, requires_contributor from ._utils import ensure_editable @@ -106,8 +106,12 @@ def send_uploads(path): except FileExistsError: pass - height = im.height * width / im.width - im.thumbnail((width, height)) + height = im.height * width // im.width + try: + im.thumbnail((width, height)) + except OSError: + # if this didn't work, the image is broken + raise NotFound() byte_io = io.BytesIO() im.save(byte_io, format='PNG') im.save(thumbnail_file, format='PNG') diff --git a/docker-compose.yml b/docker-compose.yml index 866c9e6..e1dd3dd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3' - services: data: image: mariadb:jammy