From 156367a82727a79c6f747aec48a8b25bc0428f30 Mon Sep 17 00:00:00 2001 From: Daniel Markstedt Date: Thu, 14 Oct 2021 17:47:02 -0700 Subject: [PATCH] Update handling for CD property creation, and deletion (#326) --- src/web/web.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/web/web.py b/src/web/web.py index aee589b1..ed7479dc 100644 --- a/src/web/web.py +++ b/src/web/web.py @@ -213,9 +213,13 @@ def drive_cdrom(): file_name = request.form.get("file_name") # Creating the drive properties file - from pathlib import Path - file_name = str(Path(file_name).stem) + "." + PROPERTIES_SUFFIX - properties = {"vendor": vendor, "product": product, "revision": revision, "block_size": block_size} + file_name = f"{file_name}.{PROPERTIES_SUFFIX}" + properties = { + "vendor": vendor, + "product": product, + "revision": revision, + "block_size": block_size, + } process = write_drive_properties(file_name, properties) if process["status"] == True: flash(f"Drive properties file {file_name} created") @@ -597,15 +601,14 @@ def delete(): # Delete the drive properties file, if it exists from pathlib import Path - file_name = str(Path(file_name).stem) + "." + PROPERTIES_SUFFIX - file_path = Path(cfg_dir + file_name) - if file_path.is_file(): - process = delete_file(cfg_dir + file_name) + prop_file_path = f"{cfg_dir}{file_name}.{PROPERTIES_SUFFIX}" + if Path(prop_file_path).is_file(): + process = delete_file(prop_file_path) if process["status"] == True: - flash(f"File {file_name} deleted!") + flash(f"File {prop_file_path} deleted!") return redirect(url_for("index")) else: - flash(f"Failed to delete file {file_name}!", "error") + flash(f"Failed to delete file {prop_file_path}!", "error") flash(process["msg"], "error") return redirect(url_for("index"))