mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-11-29 04:27:05 +01:00
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.
This commit is contained in:
parent
31172f38f7
commit
478228faf1
1 changed files with 3 additions and 2 deletions
|
|
@ -161,6 +161,7 @@ internal class CacheManager: IDisposable
|
||||||
IEnumerable<BanRecord> updatedBans;
|
IEnumerable<BanRecord> updatedBans;
|
||||||
|
|
||||||
// Get current time from database in local timezone (CURRENT_TIMESTAMP uses session timezone, not UTC)
|
// 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<DateTime>("SELECT CURRENT_TIMESTAMP");
|
var currentDatabaseTime = await connection.QueryFirstAsync<DateTime>("SELECT CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
// Optimization: Only get IDs for comparison if we need to check for deletions
|
// Optimization: Only get IDs for comparison if we need to check for deletions
|
||||||
|
|
@ -208,7 +209,7 @@ internal class CacheManager: IDisposable
|
||||||
updatedBans = updatedList;
|
updatedBans = updatedList;
|
||||||
|
|
||||||
// Update last check time to current database time
|
// Update last check time to current database time
|
||||||
_lastDatabaseTime = currentDatabaseTime;
|
_lastDatabaseTime = currentDatabaseTime.AddSeconds(-1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -254,7 +255,7 @@ internal class CacheManager: IDisposable
|
||||||
updatedBans = updatedList;
|
updatedBans = updatedList;
|
||||||
|
|
||||||
// Update last check time to current database time
|
// 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
|
// Optimization: Only process deletions if we have the full ID list
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue