improve checking arguments when converting the blockchain db (#10272)

* improve checking arguments when converting the blockchain db

* don't print stack traces on errors in chia db upgrade
This commit is contained in:
Arvid Norberg 2022-02-18 19:19:40 +01:00 committed by GitHub
parent 2f40ca5321
commit 9a0095b5aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 8 deletions

View File

@ -21,14 +21,17 @@ def db_cmd() -> None:
@click.pass_context
def db_upgrade_cmd(ctx: click.Context, no_update_config: bool, **kwargs) -> None:
in_db_path = kwargs.get("input")
out_db_path = kwargs.get("output")
db_upgrade_func(
Path(ctx.obj["root_path"]),
None if in_db_path is None else Path(in_db_path),
None if out_db_path is None else Path(out_db_path),
no_update_config,
)
try:
in_db_path = kwargs.get("input")
out_db_path = kwargs.get("output")
db_upgrade_func(
Path(ctx.obj["root_path"]),
None if in_db_path is None else Path(in_db_path),
None if out_db_path is None else Path(out_db_path),
no_update_config,
)
except RuntimeError as e:
print(f"FAILED: {e}")
if __name__ == "__main__":

View File

@ -65,6 +65,14 @@ def convert_v1_to_v2(in_path: Path, out_path: Path) -> None:
from contextlib import closing
if not in_path.exists():
print(f"input file doesn't exist. {in_path}")
raise RuntimeError(f"can't find {in_path}")
if in_path == out_path:
print(f"output file is the same as the input {in_path}")
raise RuntimeError("invalid conversion files")
if out_path.exists():
print(f"output file already exists. {out_path}")
raise RuntimeError("already exists")