From 8c18660a82c241851b5a5dd17c1b46af51af3622 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Mon, 3 May 2021 18:14:08 +0300 Subject: [PATCH] Fix inconsistency in accessing files between download and delete --- fileserver/fileserver.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fileserver/fileserver.py b/fileserver/fileserver.py index ebfb9eb..389d516 100644 --- a/fileserver/fileserver.py +++ b/fileserver/fileserver.py @@ -6,6 +6,7 @@ from pathlib import Path from boltons.iterutils import first from flask import Flask, request, send_from_directory, safe_join, abort, Response +from flask._compat import fspath from flask_compress import Compress from flask_cors import CORS @@ -58,7 +59,12 @@ def download(path): @app.route("/", methods=["DELETE"]) def delete(path): - path = Path(safe_join(app.config["UPLOAD_FOLDER"], path)) + path = Path( + safe_join( + fspath(app.config["UPLOAD_FOLDER"]), + fspath(path) + ) + ) if not path.exists() or path.is_file(): abort(Response(f"File {str(path)} not found", 404))