From 962e33e97116fd18ee166d49aa3b573ed4ce6378 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 15 Feb 2024 05:29:38 +0300 Subject: Verify that the file actually exist In case a filename is provided, verify that the file actually exists in the upload directory. --- qc_app/upload/rqtl2.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py index 6a8ab72..41663ff 100644 --- a/qc_app/upload/rqtl2.py +++ b/qc_app/upload/rqtl2.py @@ -267,14 +267,20 @@ def check_errors(conn, *args, **kwargs):#pylint: disable=[too-many-return-statem url_for("upload.rqtl2.select_population", pgsrc="error"), code=307) - if ("rqtl2_bundle_file" in args - and not bool(request.form.get("rqtl2_bundle_file"))): - flash("There is no file to process.", "alert-error error-rqtl2") - return redirect(url_for("upload.rqtl2.upload_rqtl2_bundle", - species_id=species_id, - population_id=population_id, - pgsrc="error"), - code=307) + if "rqtl2_bundle_file" in args: + fileuploadpage = redirect(url_for("upload.rqtl2.upload_rqtl2_bundle", + species_id=species_id, + population_id=population_id, + pgsrc="error"), + code=307) + if not bool(request.form.get("rqtl2_bundle_file")): + flash("There is no file to process.", "alert-error error-rqtl2") + return fileuploadpage + + if not Path(fullpath(request.form["rqtl2_bundle_file"])).exists(): + flash("No R/qtl2 bundle with the given name exists.", + "alert-error error-rqtl2") + return fileuploadpage if ("geno-dataset" in args and not bool(request.form.get("geno-dataset-id"))): -- cgit v1.2.3