[IMP] Use builtins "exists" click feature to check if provided files

exists
This commit is contained in:
Simon Maillard 2025-02-01 13:59:11 +00:00
parent 7d1183b140
commit ca53f46248
3 changed files with 3 additions and 10 deletions

View File

@ -0,0 +1 @@
restoredb: Use builtins click feature to check if provided paths exist

View File

@ -12,7 +12,7 @@ from odoo_openupgrade_wizard.tools.tools_system import restore_filestore
@click.option(
"--database-path",
required=True,
type=click.Path(readable=True, resolve_path=True),
type=click.Path(readable=True, resolve_path=True, exists=True),
help="Path to the database dump relative project folder.",
)
@click.option(
@ -27,7 +27,7 @@ from odoo_openupgrade_wizard.tools.tools_system import restore_filestore
@click.option(
"--filestore-path",
required=True,
type=click.Path(readable=True, resolve_path=True),
type=click.Path(readable=True, resolve_path=True, exists=True),
help="Path to the filestore backup.",
)
@click.option(
@ -60,14 +60,6 @@ def restoredb(
"postgresql to read to it."
)
# Check db path exists
if not database_path.exists():
ctx.fail(f"Database path {database_path} does not exist.")
# Check filestore path exists
if not filestore_path.exists():
ctx.fail(f"Filestore path {filestore_path} does not exist.")
# Restore the database
output = execute_pg_restore(
ctx,