diff --git a/python/web/src/templates/upload.html b/python/web/src/templates/upload.html index 4c590ef6..94fce1e1 100644 --- a/python/web/src/templates/upload.html +++ b/python/web/src/templates/upload.html @@ -21,7 +21,7 @@ {% for dir in images_subdirs %} {% endfor %} - + {% if file_server_dir_exists %} @@ -31,7 +31,7 @@ {% for dir in shared_subdirs %} {% endfor %} - + {% endif %} diff --git a/python/web/src/web.py b/python/web/src/web.py index 2de26823..959aab09 100644 --- a/python/web/src/web.py +++ b/python/web/src/web.py @@ -205,7 +205,7 @@ def get_supported_locales(): """ locales = [ {"language": x.language, "display_name": x.display_name} - for x in [*BABEL.list_translations(), Locale("en")] + for x in [*BABEL.list_translations()] ] return sorted(locales, key=lambda x: x["language"]) @@ -1038,14 +1038,14 @@ def upload_file(): if not safe_path["status"]: return make_response(safe_path["msg"], 403) server_info = piscsi_cmd.get_server_info() - destination_dir = server_info["image_dir"] + images_subdir + destination_dir = Path(server_info["image_dir"]) / images_subdir elif destination == "shared_files": safe_path = is_safe_path(Path("." + shared_subdir)) if not safe_path["status"]: return make_response(safe_path["msg"], 403) - destination_dir = FILE_SERVER_DIR + shared_subdir + destination_dir = Path(FILE_SERVER_DIR) / shared_subdir elif destination == "piscsi_config": - destination_dir = CFG_DIR + destination_dir = Path(CFG_DIR) else: return make_response(_("Unknown destination"), 403) @@ -1054,8 +1054,8 @@ def upload_file(): file_name = secure_filename(file_object.filename) tmp_file_name = "__tmp_" + file_name - save_path = path.join(destination_dir, file_name) - tmp_save_path = path.join(destination_dir, tmp_file_name) + save_path = destination_dir / file_name + tmp_save_path = destination_dir / tmp_file_name current_chunk = int(request.form["dzchunkindex"]) # Makes sure not to overwrite an existing file, diff --git a/python/web/tests/api/test_files.py b/python/web/tests/api/test_files.py index 13fbb7dd..7ab5dc20 100644 --- a/python/web/tests/api/test_files.py +++ b/python/web/tests/api/test_files.py @@ -255,7 +255,7 @@ def test_upload_file(http_client, delete_file): form_data = { "destination": "disk_images", - "images_subdir": "/", + "images_subdir": "", "dzuuid": str(uuid.uuid4()), "dzchunkindex": chunk_number, "dzchunksize": chunk_size,