improved all provider

This commit is contained in:
Simon
2026-01-15 19:17:46 +00:00
parent 27e2bcdbba
commit 6a7bc68849
2 changed files with 56 additions and 39 deletions

View File

@@ -8,7 +8,7 @@ use crate::util::requester;
// Global cache: Map<ErrorSignature, LastSentTimestamp>
static ERROR_CACHE: Lazy<DashMap<String, u64>> = Lazy::new(DashMap::new);
const COOLDOWN_SECONDS: u64 = 3600; // 1 Hour cooldown
// const COOLDOWN_SECONDS: u64 = 3600; // 1 Hour cooldown
pub fn format_error_chain(err: &dyn Error) -> String {
let mut chain_str = String::new();
@@ -40,11 +40,11 @@ pub async fn send_discord_error_report(
// Create a unique key based on error content and location
let error_signature = format!("{}-{}-{}", error_msg, file, line);
if let Some(last_sent) = ERROR_CACHE.get(&error_signature) {
if now - *last_sent < COOLDOWN_SECONDS {
if let Some(_) = ERROR_CACHE.get(&error_signature) {
// if now - *last_sent < COOLDOWN_SECONDS {
// Error is still in cooldown, skip sending
return;
}
// }
}
// Update the cache with the current timestamp