From 49e4c837d6c4df03857b4094deb1c9defd793969 Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Mon, 1 Feb 2021 13:50:07 +0100 Subject: [PATCH] fix query_result path logic --- web/app/corpora/views.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/web/app/corpora/views.py b/web/app/corpora/views.py index 91405515..3b2899d0 100644 --- a/web/app/corpora/views.py +++ b/web/app/corpora/views.py @@ -336,7 +336,7 @@ def add_query_result(): db.session.flush() db.session.refresh(query_result) try: - os.makedirs(query_result.path) + os.makedirs(os.path.dirname(query_result.path)) except OSError: logging.error('Make dir {} led to an OSError!'.format(query_result.path)) # noqa db.session.rollback() @@ -344,11 +344,9 @@ def add_query_result(): return make_response( {'redirect_url': url_for('.add_query_result')}, 500) # save the uploaded file - query_result_file_path = os.path.join(query_result.path, - query_result.filename) - form.file.data.save(query_result_file_path) + form.file.data.save(query_result.path) # parse json from file - with open(query_result_file_path, 'r') as file: + with open(query_result.path, 'r') as file: query_result_file_content = json.load(file) # parse json schema with open('app/static/json_schema/nopaque_cqi_py_results_schema.json', 'r') as file: # noqa