diff --git a/.python-version b/.python-version index 8531a3b..7ecaebe 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.12.2 +system@3.13.1 diff --git a/requirements-dev.lock b/requirements-dev.lock index d795436..8f23096 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -6,6 +6,5 @@ # features: [] # all-features: false # with-sources: false -# generate-hashes: false -e file:. diff --git a/requirements.lock b/requirements.lock index d795436..8f23096 100644 --- a/requirements.lock +++ b/requirements.lock @@ -6,6 +6,5 @@ # features: [] # all-features: false # with-sources: false -# generate-hashes: false -e file:. diff --git a/src/browser_history_merger/__init__.py b/src/browser_history_merger/__init__.py index a44a76e..493b9fe 100644 --- a/src/browser_history_merger/__init__.py +++ b/src/browser_history_merger/__init__.py @@ -188,7 +188,7 @@ def get_db_type(cur: sqlite3.Cursor) -> Literal["firefox", "chromium"]: return db_type -def get_browser_info(root_cur: sqlite3.Cursor, name: str) -> tuple[int, int, str]: +def get_browser_info(root_cur: sqlite3.Cursor, name: str) -> tuple[int, int, str] | None: res = root_cur.execute( """ SELECT @@ -202,7 +202,10 @@ def get_browser_info(root_cur: sqlite3.Cursor, name: str) -> tuple[int, int, str """, (name,), ) - browser_id, visits_time_max, database_path = res.fetchone() + res_one = res.fetchone() + if res_one is None: + return None + browser_id, visits_time_max, database_path = res_one return (browser_id, visits_time_max, database_path) @@ -250,7 +253,13 @@ def add_db( root_con: sqlite3.Connection, root_cur: sqlite3.Cursor, args: argparse.Namespace ): print("Add history to root db") - browser_id, visits_time_max, database_path = get_browser_info(root_cur, args.name) + browser_info = get_browser_info(root_cur, args.name) + if browser_info is None: + print(f"browser {args.name} is not registered to the database") + logging.debug("Cleaning up (closing db connection)") + root_con.close() + exit(1) + browser_id, visits_time_max, database_path = browser_info logging.info(f"{browser_id=}, {visits_time_max=}") logging.info(f"Source: {database_path}")