Add files via upload

This commit is contained in:
Kosztyk 2026-01-05 21:24:31 +02:00 committed by GitHub
parent dbd1805078
commit 86e67d44eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,11 +1,11 @@
// src/helpers/avToggle.ts // src/helpers/avToggle.ts
//
// Simple in-memory antivirus toggle.
// Default behaviour: enabled by default when ClamAV is configured, unless explicitly overridden.
import { import { ANTIVIRUS_ENABLED_DEFAULT, CLAMAV_CONFIGURED } from "./env";
ANTIVIRUS_ENABLED_DEFAULT,
CLAMAV_CONFIGURED,
} from "./env";
let antivirusEnabled = ANTIVIRUS_ENABLED_DEFAULT; let antivirusEnabled: boolean = CLAMAV_CONFIGURED ? ANTIVIRUS_ENABLED_DEFAULT : false;
/** /**
* Is ClamAV configured at all (CLAMAV_URL set)? * Is ClamAV configured at all (CLAMAV_URL set)?
@ -15,10 +15,12 @@ export function isAntivirusAvailable(): boolean {
} }
/** /**
* Is antivirus scanning currently enabled (and available)? * Current effective antivirus enabled state.
* If ClamAV is not configured, this always returns false.
*/ */
export function isAntivirusEnabled(): boolean { export function isAntivirusEnabled(): boolean {
return CLAMAV_CONFIGURED && antivirusEnabled; if (!CLAMAV_CONFIGURED) return false;
return antivirusEnabled;
} }
/** /**
@ -30,5 +32,13 @@ export function setAntivirusEnabled(enabled: boolean): void {
antivirusEnabled = false; antivirusEnabled = false;
return; return;
} }
antivirusEnabled = enabled; antivirusEnabled = Boolean(enabled);
} }
/**
* Useful if env / configuration changes at runtime (tests, hot reload).
*/
export function resetAntivirusEnabledToDefault(): void {
antivirusEnabled = CLAMAV_CONFIGURED ? ANTIVIRUS_ENABLED_DEFAULT : false;
}