Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

my.tinder.android: better error handing and fix case with empty db #369

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions my/tinder/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand All @@ -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,
Expand Down