Fix issues found in linting.

This commit is contained in:
Patrick Cloke 2023-01-25 15:39:39 -05:00 committed by David Robertson
parent e8a96bcc39
commit 16487c9b96
No known key found for this signature in database
GPG key ID: 903ECE108A39DEDD
2 changed files with 23 additions and 13 deletions

View file

@ -1384,15 +1384,18 @@ class SyncHandler:
# Non-lazy syncs should never include partially stated rooms. # Non-lazy syncs should never include partially stated rooms.
# Exclude all partially stated rooms from this sync. # Exclude all partially stated rooms from this sync.
results = await self.store.is_partial_state_rooms(mutable_joined_room_ids) results = await self.store.is_partial_state_rooms(mutable_joined_room_ids)
for room_id, result in results.items(): mutable_rooms_to_exclude.update(
mutable_rooms_to_exclude.add(room_id) room_id
for room_id, is_partial_state in results.items()
if is_partial_state
)
# Incremental eager syncs should additionally include rooms that # Incremental eager syncs should additionally include rooms that
# - we are joined to # - we are joined to
# - are full-stated # - are full-stated
# - became fully-stated at some point during the sync period # - became fully-stated at some point during the sync period
# (These rooms will have been omitted during a previous eager sync.) # (These rooms will have been omitted during a previous eager sync.)
forced_newly_joined_room_ids = set() forced_newly_joined_room_ids: Set[str] = set()
if since_token and not sync_config.filter_collection.lazy_load_members(): if since_token and not sync_config.filter_collection.lazy_load_members():
un_partial_stated_rooms = ( un_partial_stated_rooms = (
await self.store.get_un_partial_stated_rooms_between( await self.store.get_un_partial_stated_rooms_between(
@ -1402,8 +1405,11 @@ class SyncHandler:
) )
) )
results = await self.store.is_partial_state_rooms(un_partial_stated_rooms) results = await self.store.is_partial_state_rooms(un_partial_stated_rooms)
for room_id, result in results.items(): forced_newly_joined_room_ids.update(
forced_newly_joined_room_ids.add(room_id) room_id
for room_id, is_partial_state in results.items()
if is_partial_state
)
# Now we have our list of joined room IDs, exclude as configured and freeze # Now we have our list of joined room IDs, exclude as configured and freeze
joined_room_ids = frozenset( joined_room_ids = frozenset(

View file

@ -1275,7 +1275,9 @@ class RoomWorkerStore(CacheInvalidationWorkerStore):
return entry is not None return entry is not None
@cachedList(cached_method_name="is_partial_State_room", list_name="room_ids") @cachedList(cached_method_name="is_partial_State_room", list_name="room_ids")
async def is_partial_state_rooms(self, room_ids: StrCollection) -> Mapping[str, bool]: async def is_partial_state_rooms(
self, room_ids: StrCollection
) -> Mapping[str, bool]:
"""Checks if this room has partial state. """Checks if this room has partial state.
Returns true if this is a "partial-state" room, which means that the state Returns true if this is a "partial-state" room, which means that the state
@ -1283,13 +1285,15 @@ class RoomWorkerStore(CacheInvalidationWorkerStore):
complete. complete.
""" """
entries = set(await self.db_pool.simple_select_many_batch( entries = set(
table="partial_state_rooms", await self.db_pool.simple_select_many_batch(
column="room_id", table="partial_state_rooms",
iterable=room_ids, column="room_id",
retcols=("room_id",), iterable=room_ids,
desc="is_partial_state_room", retcols=("room_id",),
)) desc="is_partial_state_room",
)
)
return {room_id: room_id in entries for room_id in room_ids} return {room_id: room_id in entries for room_id in room_ids}