Skip to content

Commit

Permalink
prints
Browse files Browse the repository at this point in the history
  • Loading branch information
squeaky-pl committed Nov 6, 2024
1 parent d91bdc5 commit aadad41
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions inbox/mailsync/backends/imap/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ def remove_deleted_uids(account_id: int, folder_id: int, uids: Iterable[int]) ->
with session_scope(account_id) as db_session:
category_type = Account.get(account_id, db_session).category_type

print("before message_ids_and_uid")

message_ids_and_uid = (
db_session.query(ImapUid.message_id, ImapUid.msg_uid)
.filter(
Expand All @@ -271,10 +273,16 @@ def remove_deleted_uids(account_id: int, folder_id: int, uids: Iterable[int]) ->
.all()
)

print("after message_ids_and_uid")

print("before uids_by_message_id")

uids_by_message_id = defaultdict(list)
for message_id, message_uid in message_ids_and_uid:
uids_by_message_id[message_id].append(message_uid)

print("after uids_by_message_id")

for message_id, message_uids in uids_by_message_id.items():
with session_scope(account_id) as db_session:
db_session.query(ImapUid).filter(
Expand All @@ -287,6 +295,8 @@ def remove_deleted_uids(account_id: int, folder_id: int, uids: Iterable[int]) ->
synchronize_session=False
)

print(message_id, len(message_uids))

deleted_uid_count += len(message_uids)

message = db_session.query(Message).get(message_id)
Expand Down Expand Up @@ -321,7 +331,10 @@ def remove_deleted_uids(account_id: int, folder_id: int, uids: Iterable[int]) ->
# 'deleted' and wait for the asynchronous
# dangling-message-collector to delete them.
message.mark_for_deletion()

print("before commit")
db_session.commit()
print("after commit")
log.info("Deleted expunged UIDs", count=deleted_uid_count)


Expand Down

0 comments on commit aadad41

Please sign in to comment.