File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818# along with this program. If not, see <https://www.gnu.org/licenses/>.
1919
2020import tomllib
21+ from pathlib import Path
2122
2223from dotenv .main import DotEnv
2324
@@ -50,13 +51,20 @@ def load_config_file(filepath: str) -> dict:
5051 return {k .lower (): v for k , v in DotEnv (filepath ).dict ().items ()}
5152
5253
54+ def _remove_if_exists (path : Path ) -> None :
55+ if path .exists ():
56+ path .unlink ()
57+
58+
5359def validate_and_save_node_settings (
5460 config_filepath : str ,
5561 node_type : NodeType ,
5662 node_mode : NodeMode ,
5763) -> BaseNodeSettings :
5864 data = load_config_file (config_filepath )
5965 settings_type = SETTINGS_MAP [(node_type .value , node_mode .value )]
66+ settings_type .model_validate (data )
67+ _remove_if_exists (NODE_SETTINGS_PATH )
6068 write_node_settings_file (path = NODE_SETTINGS_PATH , settings_type = settings_type , data = data )
6169 return settings_type ()
6270
@@ -74,4 +82,6 @@ def save_internal_settings(
7482 'backup_run' : backup_run ,
7583 'pull_config_for_schain' : pull_config_for_schain ,
7684 }
85+ InternalSettings .model_validate (data )
86+ _remove_if_exists (INTERNAL_SETTINGS_PATH )
7787 write_internal_settings_file (path = INTERNAL_SETTINGS_PATH , data = data )
You can’t perform that action at this time.
0 commit comments