diff options
Diffstat (limited to 'qc_app/upload/rqtl2.py')
-rw-r--r-- | qc_app/upload/rqtl2.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py index 31d5a9d..e691636 100644 --- a/qc_app/upload/rqtl2.py +++ b/qc_app/upload/rqtl2.py @@ -13,11 +13,11 @@ import MySQLdb as mdb from redis import Redis from MySQLdb.cursors import DictCursor from werkzeug.utils import secure_filename -from werkzeug.exceptions import NotFound, BadRequest from flask import ( flash, escape, request, + jsonify, url_for, redirect, Response, @@ -254,13 +254,21 @@ def upload_rqtl2_bundle_chunked_get(# pylint: disable=["unused-argument"] filename = request.args.get("resumableFilename", type=str) or "" chunk = request.args.get("resumableChunkNumber", type=int) or 0 if not(fileid or filename or chunk): - raise BadRequest("At least one required query parameter is missing.") + return jsonify({ + "message": "At least one required query parameter is missing.", + "error": "BadRequest", + "statuscode": 400 + }), 400 if Path(chunks_directory(fileid), chunk_name(filename, chunk)).exists(): return "OK" - raise NotFound(description=f"Chunk {chunk} was not found.") + return jsonify({ + "message": f"Chunk {chunk} was not found.", + "error": "NotFound", + "statuscode": 404 + }), 404 def __merge_chunks__(targetfile: Path, chunkpaths: tuple[Path, ...]) -> Path: @@ -294,7 +302,13 @@ def upload_rqtl2_bundle_chunked_post(species_id: int, population_id: int): _targetfile = Path(app.config["UPLOAD_FOLDER"], _fileid) if _targetfile.exists(): - raise BadRequest("The file has already been uploaded.") + return jsonify({ + "message": ( + "A file with a similar unique identifier has previously been " + "uploaded and possibly is/has being/been processed."), + "error": "BadRequest", + "statuscode": 400 + }), 400 # save chunk data chunks_directory(_fileid).mkdir(exist_ok=True) |