From 8a8a1ebb0e8eeaa612bf78e8f3aa6c2fc3942df4 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Wed, 3 Apr 2024 19:58:44 +0100 Subject: [PATCH] my.tinder.android: better error handing and fix case with empty db --- my/tinder/android.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/my/tinder/android.py b/my/tinder/android.py index 7e5f535..56ee1cb 100644 --- a/my/tinder/android.py +++ b/my/tinder/android.py @@ -92,7 +92,10 @@ def _entities() -> Iterator[Res[_Entity]]: for idx, path in enumerate(paths): logger.info(f'processing [{idx:>{width}}/{total:>{width}}] {path}') with sqlite_connection(path, immutable=True, row_factory='row') as db: - yield from _handle_db(db) + try: + yield from _handle_db(db) + except Exception as e: + yield e def _handle_db(db: sqlite3.Connection) -> Iterator[Res[_Entity]]: @@ -103,8 +106,9 @@ def _handle_db(db: sqlite3.Connection) -> Iterator[Res[_Entity]]: # shit, sometime in 2023 profile_user_view stoppped containing user profile.. # presumably the most common from_id/to_id would be our own username counter = Counter([id_ for (id_,) in db.execute('SELECT from_id FROM message UNION ALL SELECT to_id FROM message')]) - [(you_id, _)] = counter.most_common(1) - yield Person(id=you_id, name='you') + if len(counter) > 0: # this might happen if db is empty (e.g. user got logged out) + [(you_id, _)] = counter.most_common(1) + yield Person(id=you_id, name='you') for row in chain( user_profile_rows,