v0.3.24: 清理设置4个后端接线 — 白名单/cookie检测/空间校准开关

补全前端4个控制项的后端实现:
- cleanup_whitelist_dirs → cleanupCloudFiles + cleanupAllBySpaceThreshold 读取并传递
- cleanup_auto_refresh_storage → scheduleStorageRefresh 读取开关,false时跳过
- cleanup_verify_enabled + cleanup_verify_interval → 新增Cookie验证调度器
- CloudCleanupDriver 接口 + baidu.driver 签名同步支持 whitelistDirs 可选参数

验证: 4个key从仅前端 → 全部有后端读取模块
This commit is contained in:
2026-05-17 18:10:12 +08:00
parent 1fd64e0788
commit 32dcc44524
3 changed files with 54 additions and 6 deletions

View File

@@ -183,12 +183,17 @@ async function start(): Promise<void> {
let storageRefreshTimer: NodeJS.Timeout | null = null;
const scheduleStorageRefresh = () => {
if (storageRefreshTimer) clearTimeout(storageRefreshTimer);
// Check if auto refresh is enabled
let enabled = true;
let intervalMinutes = 180; // default
try {
const { getSystemConfig } = require('./admin/system-config.service');
const autoVal = getSystemConfig('cleanup_auto_refresh_storage');
if (autoVal === 'false' || autoVal === '0') enabled = false;
const val = getSystemConfig('storage_refresh_interval');
if (val) { const n = parseInt(val, 10); if (n >= 5 && n <= 1440) intervalMinutes = n; }
} catch {}
if (!enabled) { console.log('[Storage] Auto refresh disabled, skipping'); return; }
const ms = intervalMinutes * 60 * 1000;
console.log(`[Storage] Next refresh in ${intervalMinutes} minutes`);
storageRefreshTimer = setTimeout(() => {
@@ -202,6 +207,35 @@ async function start(): Promise<void> {
setTimeout(() => scheduleStorageRefresh(), 60000);
// Cookie verification scheduler — periodically test cloud connections
let verifyTimer: NodeJS.Timeout | null = null;
const scheduleVerify = () => {
if (verifyTimer) clearTimeout(verifyTimer);
let enabled = false;
let intervalMinutes = 60; // default every hour
try {
const { getSystemConfig } = require('./admin/system-config.service');
const enabledVal = getSystemConfig('cleanup_verify_enabled');
if (enabledVal === 'true' || enabledVal === '1') enabled = true;
const intVal = getSystemConfig('cleanup_verify_interval');
if (intVal) { const n = parseInt(intVal, 10); if (n >= 5 && n <= 1440) intervalMinutes = n; }
} catch {}
if (!enabled) return;
const ms = intervalMinutes * 60 * 1000;
verifyTimer = setTimeout(async () => {
try {
const { getActiveCloudConfigs, testCloudConnection } = require('./cloud/credential.service');
const configs = getActiveCloudConfigs();
for (const c of configs) {
try { await testCloudConnection(c.id); } catch {}
}
} catch (e: any) { console.error('[Verify] Error:', e.message); }
scheduleVerify();
}, ms);
};
// Start verification 2 minutes after startup
setTimeout(() => scheduleVerify(), 120000);
// Daily Report scheduler — check every 60 seconds
const DAILY_REPORT_CHECK_INTERVAL = 60 * 1000;
setInterval(() => {