From 478228faf147ac4e2d67e7771e6d4befaeadaaf9 Mon Sep 17 00:00:00 2001 From: Ravid-A Date: Wed, 25 Nov 2026 14:26:46 +0200 Subject: [PATCH] Overlap ban cache refreshes by one second DateTimeKind=Utc writes the refresh timestamp with a trailing Z. SQLite compares dates as text, so "10:00:05" no longer matched ">= 10:00:05Z" and a ban saved in the same second as a refresh, after it ran, could be missed. Rows fetched twice are ignored unless their status changed. --- CS2-SimpleAdmin/Managers/CacheManager.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CS2-SimpleAdmin/Managers/CacheManager.cs b/CS2-SimpleAdmin/Managers/CacheManager.cs index 2e515fa..6b0290a 100644 --- a/CS2-SimpleAdmin/Managers/CacheManager.cs +++ b/CS2-SimpleAdmin/Managers/CacheManager.cs @@ -161,6 +161,7 @@ internal class CacheManager: IDisposable IEnumerable updatedBans; // Get current time from database in local timezone (CURRENT_TIMESTAMP uses session timezone, not UTC) + // Overlap refreshes by a second: SQLite compares dates as text, and "10:00:05" sorts before "10:00:05Z" var currentDatabaseTime = await connection.QueryFirstAsync("SELECT CURRENT_TIMESTAMP"); // Optimization: Only get IDs for comparison if we need to check for deletions @@ -208,7 +209,7 @@ internal class CacheManager: IDisposable updatedBans = updatedList; // Update last check time to current database time - _lastDatabaseTime = currentDatabaseTime; + _lastDatabaseTime = currentDatabaseTime.AddSeconds(-1); } else { @@ -254,7 +255,7 @@ internal class CacheManager: IDisposable updatedBans = updatedList; // Update last check time to current database time - _lastDatabaseTime = currentDatabaseTime; + _lastDatabaseTime = currentDatabaseTime.AddSeconds(-1); } // Optimization: Only process deletions if we have the full ID list