Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix issues found in linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Jan 25, 2023
1 parent 6388f19 commit 572ef21
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
16 changes: 11 additions & 5 deletions synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -1384,15 +1384,18 @@ async def generate_sync_result(
# Non-lazy syncs should never include partially stated rooms.
# Exclude all partially stated rooms from this sync.
results = await self.store.is_partial_state_rooms(mutable_joined_room_ids)
for room_id, result in results.items():
mutable_rooms_to_exclude.add(room_id)
mutable_rooms_to_exclude.update(
room_id
for room_id, is_partial_state in results.items()
if is_partial_state
)

# Incremental eager syncs should additionally include rooms that
# - we are joined to
# - are full-stated
# - became fully-stated at some point during the sync period
# (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():
un_partial_stated_rooms = (
await self.store.get_un_partial_stated_rooms_between(
Expand All @@ -1402,8 +1405,11 @@ async def generate_sync_result(
)
)
results = await self.store.is_partial_state_rooms(un_partial_stated_rooms)
for room_id, result in results.items():
forced_newly_joined_room_ids.add(room_id)
forced_newly_joined_room_ids.update(
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
joined_room_ids = frozenset(
Expand Down
20 changes: 12 additions & 8 deletions synapse/storage/databases/main/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,21 +1275,25 @@ async def is_partial_state_room(self, room_id: str) -> bool:
return entry is not None

@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.
Returns true if this is a "partial-state" room, which means that the state
at events in the room, and `current_state_events`, may not yet be
complete.
"""

entries = set(await self.db_pool.simple_select_many_batch(
table="partial_state_rooms",
column="room_id",
iterable=room_ids,
retcols=("room_id",),
desc="is_partial_state_room",
))
entries = set(
await self.db_pool.simple_select_many_batch(
table="partial_state_rooms",
column="room_id",
iterable=room_ids,
retcols=("room_id",),
desc="is_partial_state_room",
)
)

return {room_id: room_id in entries for room_id in room_ids}

Expand Down

0 comments on commit 572ef21

Please sign in to comment.