From 992095ffd574327fc1d48a19fe29ab548438bb6e Mon Sep 17 00:00:00 2001 From: Daniel Markstedt Date: Thu, 14 Oct 2021 17:46:25 -0700 Subject: [PATCH] Config saving/loading validation (#331) * Add validation for config loading/deleting * Disallow saving an empty config * Typo fix * Update help text for clarity * Consistent capitalization --- src/web/file_cmds.py | 2 ++ src/web/templates/index.html | 8 ++++---- src/web/web.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/web/file_cmds.py b/src/web/file_cmds.py index 30b8ddf0..a39e56dd 100644 --- a/src/web/file_cmds.py +++ b/src/web/file_cmds.py @@ -225,6 +225,8 @@ def write_config(file_name): try: with open(file_name, "w") as json_file: devices = list_devices()["device_list"] + if len(devices) == 0: + return {"status": False, "msg": "No attached devices."} for device in devices: # Remove keys that we don't want to store in the file del device["status"] diff --git a/src/web/templates/index.html b/src/web/templates/index.html index 3bb5fd64..02723f75 100644 --- a/src/web/templates/index.html +++ b/src/web/templates/index.html @@ -12,7 +12,7 @@

- {% for config in config_files %} {% endfor %} @@ -103,9 +103,9 @@
- Valid Image Files + Image File Management
    -
  • A list of image files in {{base_dir}} that RaSCSI has identified as valid.
  • +
  • Manage image files in the active RaSCSI image directory: {{base_dir}}
  • Select a valid SCSI ID and LUN to attach to. Unless you know what you're doing, always use LUN 0.
  • If RaSCSI was unable to detect the device type associated with the image, you can choose the type from the dropdown.
  • Types: SAHD = SASI HDD | SCHD = SCSI HDD | SCRM = Removable | SCMO = Magneto-Optical | SCCD = CD-ROM | SCBR = Host Bridge | SCDP = DaynaPORT
  • @@ -265,7 +265,7 @@
    - Download File from web and create HFS CD (Macintosh) + Download File from Web and Create HFS CD (Macintosh)
    • Given a URL this will download a file, create a HFS iso, and mount it on the SCSI ID given.
    • Requires a compatible CD-ROM driver installed on the target system.
    • diff --git a/src/web/web.py b/src/web/web.py index fcc4e46c..aee589b1 100644 --- a/src/web/web.py +++ b/src/web/web.py @@ -236,7 +236,7 @@ def config_save(): flash(process["msg"]) return redirect(url_for("index")) else: - flash(f"Failed to saved config to {file_name}!", "error") + flash(f"Failed to save config to {file_name}!", "error") flash(process['msg'], "error") return redirect(url_for("index"))