Refactor database connection handling in StorageCollector and reduce log verbosity in RoomServer to minimize spam during idle periods

This commit is contained in:
Lloyd
2025-12-18 22:12:25 +00:00
parent d321612670
commit 4e1eb888e5
2 changed files with 4 additions and 13 deletions
@@ -198,7 +198,8 @@ class StorageCollector:
Node name if found, None otherwise
"""
try:
with self.sqlite_handler.get_connection() as conn:
import sqlite3
with sqlite3.connect(self.sqlite_handler.sqlite_path) as conn:
result = conn.execute(
"SELECT node_name FROM adverts WHERE pubkey = ? AND node_name IS NOT NULL ORDER BY last_seen DESC LIMIT 1",
(pubkey,)
+2 -12
View File
@@ -500,15 +500,11 @@ class RoomServer:
# Get all clients for this room
all_clients = self.acl.get_all_clients()
if not all_clients:
logger.debug(f"Room '{self.room_name}': No authenticated clients found")
# Only log once when transitioning from clients to no clients
# to avoid log spam when room is idle
self.next_push_time = time.time() + 1.0 # Check again in 1 second
continue
logger.debug(
f"Room '{self.room_name}': Found {len(all_clients)} authenticated client(s), "
f"checking for unsynced messages"
)
# SAFETY: Limit number of clients
if len(all_clients) > MAX_CLIENTS_PER_ROOM:
logger.warning(
@@ -573,12 +569,6 @@ class RoomServer:
last_activity=time.time()
)
# Log the sync check for debugging
logger.debug(
f"Room '{self.room_name}': Checking client 0x{client.id.get_public_key()[0]:02X} "
f"for messages newer than sync_since={sync_since:.1f}"
)
# Find next unsynced message for this client
unsynced = self.db.get_unsynced_messages(
room_hash=f"0x{self.room_hash:02X}",