aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-02-15 05:29:38 +0300
committerFrederick Muriuki Muriithi2024-02-15 05:31:04 +0300
commit962e33e97116fd18ee166d49aa3b573ed4ce6378 (patch)
treed673d0af9fbeaaec757b724194e3d5f1022fd0d2
parent164d53f5f53a469730a66a0be0af7016c53f2aa5 (diff)
downloadgn-uploader-962e33e97116fd18ee166d49aa3b573ed4ce6378.tar.gz
Verify that the file actually exist
In case a filename is provided, verify that the file actually exists in the upload directory.
-rw-r--r--qc_app/upload/rqtl2.py22
1 files 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"))):