fix: refuse a --bios-dir that does not exist

This commit is contained in:
Abdessamad Derraz committed 2026-10-18 08:39:27 +02:00
1 parent 4240c98359
commit b23f5b04ad
7 files changed
+57 -1

No files matched your search

+2
View File
@@ -29,6 +29,7 @@ from pathlib import Path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from common import (
require_directory,
list_registered_platforms,
load_database,
load_platform_config,
@@ -429,6 +430,7 @@ def main() -> None:
"--create-issues", action="store_true", help="Output GitHub Issue bodies"
)
args = parser.parse_args()
require_directory(args.bios_dir)
if not os.path.exists(args.db):
print(f"Error: {args.db} not found. Run generate_db.py first.", file=sys.stderr)
+11
View File
@@ -31,6 +31,17 @@ except ImportError:
def require_directory(path: str, flag: str = "--bios-dir") -> None:
"""Stop on a folder that does not exist.
identity --strict, dedup, auto_fetch, romset_recipes and generate_pack
read a mistyped --bios-dir as an empty collection and passed: 0
conflicts, 0 duplicates, a pack of nothing.
"""
if not os.path.isdir(path):
raise SystemExit(f"ERROR: {flag} {path} is not a directory")
class DatabaseUnreadable(FileNotFoundError):
"""The database a command was pointed at does not exist or is not JSON."""
+2 -1
View File
@@ -28,7 +28,7 @@ from collections import defaultdict
from pathlib import Path
sys.path.insert(0, os.path.dirname(__file__))
from common import compute_hashes, write_text_atomic
from common import compute_hashes, require_directory, write_text_atomic
DEFAULT_BIOS_DIR = "bios"
@@ -319,6 +319,7 @@ def main() -> None:
)
parser.add_argument("--bios-dir", default=DEFAULT_BIOS_DIR)
args = parser.parse_args()
require_directory(args.bios_dir)
print(f"Scanning {args.bios_dir}/ for duplicates...")
if args.dry_run:
+2
View File
@@ -33,6 +33,7 @@ from pathlib import Path
sys.path.insert(0, os.path.dirname(__file__))
from common import resolve_platform_cores as _platform_cores
from common import (
require_directory,
target_listing_line,
suggest_names,
require_platform,
@@ -2977,6 +2978,7 @@ def _main(held: contextlib.ExitStack) -> None:
packresolve.set_offline(bool(args.offline))
if args.platform:
require_platform(args.platform, args.platforms_dir)
require_directory(args.bios_dir)
_refuse_unapplied_flags(args, parser)
# Quick-exit modes: --verify-packs alone = verify existing packs only
+3
View File
@@ -151,6 +151,9 @@ def main() -> int:
"--strict", action="store_true", help="exit non-zero when any is found"
)
args = parser.parse_args()
from common import require_directory # noqa: PLC0415
require_directory(args.bios_dir)
duplicates = scan(args.bios_dir)
if args.json:
+2
View File
@@ -35,6 +35,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from common import (
require_directory,
load_database,
load_emulator_profiles,
load_platform_config,
@@ -471,6 +472,7 @@ def main() -> int:
help="recipe snapshot file, or a directory of them",
)
args = parser.parse_args()
require_directory(args.bios_dir)
_resolve_modes(args)
db = load_database(args.db)