mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 10:07:48 -06:00
fix: stop auto_fetch on a mistyped --db
This commit is contained in:
1 parent
a34949d9e4
commit
9f9fe2bfec
4 files changed
+40
-14
No files matched your search
@@ -9,7 +9,7 @@ from pathlib import Path
|
||||
from core.cli import InputMissing
|
||||
from core.hashing import cut_md5_owner
|
||||
from core.memo import DerivedView
|
||||
from core.paths import REPO_ROOT
|
||||
from core.paths import DB_FILE, REPO_ROOT
|
||||
|
||||
|
||||
class DatabaseUnreadable(InputMissing):
|
||||
@@ -50,6 +50,17 @@ def load_database(db_path: str) -> dict:
|
||||
) from None
|
||||
|
||||
|
||||
def load_optional_database(db_path: str) -> dict | None:
|
||||
"""The database, or None when the default one is absent.
|
||||
|
||||
The default may be missing, a --db that was named must exist: a typo
|
||||
beside the real file was read as an empty collection.
|
||||
"""
|
||||
if db_path == DB_FILE and not os.path.exists(db_path):
|
||||
return None
|
||||
return load_database(db_path)
|
||||
|
||||
|
||||
def _index_paths(files: dict) -> dict[str, tuple[str, dict]]:
|
||||
"""Normalized path -> (sha1, record)."""
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user