fix(logs): Make empty log pruning more robust by including sessions with missing metadata
This commit is contained in:
@@ -243,14 +243,17 @@ class LogRegistry:
|
||||
start_time = start_time_raw
|
||||
is_whitelisted = session_data.get('whitelisted', False)
|
||||
|
||||
# Heuristic: also include non-whitelisted sessions that have 0 messages or 0 KB size
|
||||
metadata = session_data.get('metadata', {}) or {}
|
||||
message_count = metadata.get('message_count', -1)
|
||||
size_kb = metadata.get('size_kb', -1)
|
||||
is_empty = (message_count == 0 or size_kb == 0)
|
||||
# Heuristic: also include non-whitelisted sessions that have 0 messages or 0 KB size, or missing metadata
|
||||
metadata = session_data.get('metadata')
|
||||
if metadata is None:
|
||||
is_empty = True
|
||||
else:
|
||||
message_count = metadata.get('message_count', -1)
|
||||
size_kb = metadata.get('size_kb', -1)
|
||||
is_empty = (message_count == 0 or size_kb == 0)
|
||||
|
||||
if start_time is not None and not is_whitelisted:
|
||||
if start_time < cutoff_datetime or is_empty:
|
||||
if not is_whitelisted:
|
||||
if is_empty or (start_time is not None and start_time < cutoff_datetime):
|
||||
old_sessions.append({
|
||||
'session_id': session_id,
|
||||
'path': session_data.get('path'),
|
||||
|
||||
Reference in New Issue
Block a user