Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

add_diff_uids #972

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 13 additions & 1 deletion inbox/mailsync/backends/imap/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,11 +877,17 @@ def condstore_refresh_flags(self, crispin_client: CrispinClient) -> None:
self.account_id, db_session, self.folder_id
)

new_uids = (
remote_uids.difference(local_uids) if self.state != "initial" else None
)
expunged_uids = local_uids.difference(remote_uids)
del local_uids # free memory as soon as possible
max_remote_uid = max(remote_uids) if remote_uids else 0
del remote_uids # free memory as soon as possible

if new_uids:
self.download_and_commit_uids(crispin_client, new_uids)

if expunged_uids:
# If new UIDs have appeared since we last checked in
# get_new_uids, save them first. We want to always have the
Expand Down Expand Up @@ -922,17 +928,23 @@ def refresh_flags_impl(self, crispin_client: CrispinClient, max_uids: int) -> No

with self.global_lock:
# Check for any deleted messages.
remote_uids = crispin_client.all_uids()
remote_uids = set(crispin_client.all_uids())

with session_scope(self.namespace_id) as db_session:
local_uids = common.local_uids(
self.account_id, db_session, self.folder_id
)

new_uids = (
remote_uids.difference(local_uids) if self.state != "initial" else None
)
expunged_uids = local_uids.difference(remote_uids)
del local_uids # free memory as soon as possible
del remote_uids # free memory as soon as possible

if new_uids:
self.download_and_commit_uids(crispin_client, new_uids)

if expunged_uids:
with self.syncmanager_lock:
common.remove_deleted_uids(
Expand Down
Loading