Skip to content

Commit

Permalink
added disk-setup specfic sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
natankeddem committed May 12, 2024
1 parent bba6410 commit 779d25d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions autopve/tabs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,14 @@ def __init__(self, answer: str) -> None:
"btrfs.hdsize": {"description": ""},
}
super().__init__(answer, type="disk-setup", keys=keys)

def key_valid(self, key: str) -> bool:
if super().key_valid(key) is True:
if "filter" in key and "disk_list" in self._elements.keys():
el.Notification(f"Can not add {key} when disk_list is utilized!", type="negative", timeout=5)
return False
elif key == "disk_list" and any("filter" in k for k in self._elements.keys()):
el.Notification("Can not add disk_list when a filter is utilized!", type="negative", timeout=5)
return False
return True
return False
6 changes: 6 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ def response(answer: str, system_info: Dict[str, Any], data: Dict[str, Any]):
if "network" in default_data and "network" in answer_data:
default_data["network"].update(answer_data["network"])
if "disk-setup" in default_data and "disk-setup" in answer_data:
if any("filter" in k for k in answer_data["disk-setup"]):
del default_data["disk-setup"]["disk_list"]
if "disk_list" in answer_data["disk-setup"]:
for key in list(default_data["disk-setup"].keys()):
if "filter" in key:
del default_data["disk-setup"][key]
default_data["disk-setup"].update(answer_data["disk-setup"])
return response(answer, system_info, default_data)
return response("Default", system_info, default_data)
Expand Down

0 comments on commit 779d25d

Please sign in to comment.