Skip to content

Commit

Permalink
More IntSet generators
Browse files Browse the repository at this point in the history
  • Loading branch information
squeaky-pl committed Nov 5, 2024
1 parent d3187f0 commit 90be6a0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions inbox/mailsync/backends/gmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"""

import itertools
from collections import OrderedDict
from datetime import datetime, timedelta
from threading import Semaphore
Expand Down Expand Up @@ -295,8 +296,9 @@ def initial_sync_impl(self, crispin_client: "CrispinClient") -> None:
)
)

uids_to_download = sorted(unknown_uids - inbox_uids) + sorted(
unknown_uids & inbox_uids
uids_to_download = itertools.chain(
reversed(unknown_uids & inbox_uids),
reversed(unknown_uids - inbox_uids),
)

del inbox_uids # free up memory as soon as possible
Expand All @@ -305,7 +307,7 @@ def initial_sync_impl(self, crispin_client: "CrispinClient") -> None:

del unknown_uids # free up memory as soon as possible

for uids in chunk(reversed(uids_to_download), 1024):
for uids in chunk(uids_to_download, 1024):
g_metadata = crispin_client.g_metadata(uids)
# UIDs might have been expunged since sync started, in which
# case the g_metadata call above will return nothing.
Expand Down

0 comments on commit 90be6a0

Please sign in to comment.