From 7ec1495babe6be6f0ac1c89e3b79fc6a703bf369 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 21 Jan 2025 10:41:37 -0600 Subject: Extract target file path computation to a utility function. --- uploader/files/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'uploader') diff --git a/uploader/files/views.py b/uploader/files/views.py index 06481ee..7e2ef0b 100644 --- a/uploader/files/views.py +++ b/uploader/files/views.py @@ -8,6 +8,11 @@ from .chunks import chunk_name, chunks_directory files = Blueprint("files", __name__) +def target_file(fileid: str) -> Path: + """Compute the full path for the target file.""" + return Path(app.config["UPLOAD_FOLDER"], fileid) + + @files.route("/upload/resumable", methods=["GET"]) def resumable_upload_get(): """Used for checking whether **ALL** chunks have been uploaded.""" @@ -56,7 +61,7 @@ def resumable_upload_post(): "resumableFilename", default="", type=str) or "" _fileid = request.form.get( "resumableIdentifier", default="", type=str) or "" - _targetfile = Path(app.config["UPLOAD_FOLDER"], _fileid) + _targetfile = target_file(_fileid) if _targetfile.exists(): return jsonify({ -- cgit v1.2.3