v0.3.21: 修复存储空间自动刷新不生效
根因: 1. refreshAllStorageInfo 只过滤 quark, 百度等其他网盘永远不会刷新 2. 主调度器硬编码 60 分钟, 未读取 storage_refresh_interval 配置(用户设的180分钟) 3. 条件检查用 totalBytes/usedBytes, 百度返回对象无此字段 → 永远跳过 修复: - refreshAllStorageInfo: 改为驱动注册表模式, 支持 quark+baidu, 兼容不同驱动返回格式 - main.ts: 用 setTimeout 链替代 setInterval, 每次动态读 storage_refresh_interval, 修改后无需重启即生效
This commit is contained in:
@@ -178,10 +178,28 @@ async function start(): Promise<void> {
|
||||
setInterval(() => { checkAndRunScheduledCleanup().catch(err => console.error('[Cleanup] Scheduler error:', err.message)); }, CLEANUP_INTERVAL);
|
||||
setTimeout(() => { checkAndRunScheduledCleanup().catch(err => console.error('[Cleanup] Initial check error:', err.message)); }, 30000);
|
||||
|
||||
// Storage info refresh scheduler — every 60 minutes
|
||||
const STORAGE_REFRESH_INTERVAL = 60 * 60 * 1000;
|
||||
setInterval(() => { refreshAllStorageInfo().catch(err => console.error('[Storage] Refresh error:', err.message)); }, STORAGE_REFRESH_INTERVAL);
|
||||
// Storage info refresh scheduler — dynamic interval from system_configs.storage_refresh_interval
|
||||
// Uses setTimeout chain so interval changes take effect without restart
|
||||
let storageRefreshTimer: NodeJS.Timeout | null = null;
|
||||
const scheduleStorageRefresh = () => {
|
||||
if (storageRefreshTimer) clearTimeout(storageRefreshTimer);
|
||||
let intervalMinutes = 180; // default
|
||||
try {
|
||||
const { getSystemConfig } = require('./admin/system-config.service');
|
||||
const val = getSystemConfig('storage_refresh_interval');
|
||||
if (val) { const n = parseInt(val, 10); if (n >= 5 && n <= 1440) intervalMinutes = n; }
|
||||
} catch {}
|
||||
const ms = intervalMinutes * 60 * 1000;
|
||||
console.log(`[Storage] Next refresh in ${intervalMinutes} minutes`);
|
||||
storageRefreshTimer = setTimeout(() => {
|
||||
refreshAllStorageInfo().catch(err => console.error('[Storage] Refresh error:', err.message));
|
||||
scheduleStorageRefresh(); // re-schedule with possibly updated interval
|
||||
}, ms);
|
||||
};
|
||||
// First run 60s after startup
|
||||
setTimeout(() => { refreshAllStorageInfo().catch(err => console.error('[Storage] Initial refresh error:', err.message)); }, 60000);
|
||||
// Schedule first periodic refresh (delay = configured interval)
|
||||
setTimeout(() => scheduleStorageRefresh(), 60000);
|
||||
|
||||
|
||||
// Daily Report scheduler — check every 60 seconds
|
||||
|
||||
Reference in New Issue
Block a user