mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-08-24 10:05:29 -05:00
Prevent a crash that happens when config["harvester"]["plot_directories"] is not a list (#13551)
This commit is contained in:
@@ -69,7 +69,7 @@ class PlotRefreshResult:
|
||||
def get_plot_directories(root_path: Path, config: Dict = None) -> List[str]:
|
||||
if config is None:
|
||||
config = load_config(root_path, "config.yaml")
|
||||
return config["harvester"]["plot_directories"]
|
||||
return config["harvester"]["plot_directories"] or []
|
||||
|
||||
|
||||
def get_plot_filenames(root_path: Path) -> Dict[Path, List[Path]]:
|
||||
@@ -93,6 +93,8 @@ def add_plot_directory(root_path: Path, str_path: str) -> Dict:
|
||||
with lock_and_load_config(root_path, "config.yaml") as config:
|
||||
if str(Path(str_path).resolve()) in get_plot_directories(root_path, config):
|
||||
raise ValueError(f"Path already added: {path}")
|
||||
if not config["harvester"]["plot_directories"]:
|
||||
config["harvester"]["plot_directories"] = []
|
||||
config["harvester"]["plot_directories"].append(str(Path(str_path).resolve()))
|
||||
save_config(root_path, "config.yaml", config)
|
||||
return config
|
||||
|
||||
Reference in New Issue
Block a user