🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🌐 chore: translate non-English comments to English in server/utils (#12042)
LobeHub Botb1c6bdb1921e
diff --git a/src/server/utils/tempFileManager.ts b/src/server/utils/tempFileManager.tsindex 4b47c7136f3..c9528b13726 100644--- a/src/server/utils/tempFileManager.ts+++ b/src/server/utils/tempFileManager.ts@@ -3,21 +3,21 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';/**- * 安全存储临时文件工具类+ * Utility class for safely storing temporary files*/export class TempFileManager {private readonly tempDir: string;private filePaths: Set<string> = new Set();constructor(dirname: string) {- // 创建唯一临时目录 (跨平台安全)+ // Create unique temporary directory (cross-platform safe)this.tempDir = mkdtempSync(join(tmpdir(), dirname));- // 注册退出清理钩子+ // Register cleanup hook for process exitthis.registerCleanupHook();}/**- * 将 Uint8Array 写入临时文件+ * Write Uint8Array data to a temporary file*/async writeTempFile(data: Uint8Array, name: string): Promise<string> {@@ -28,35 +28,35 @@ export class TempFileManager {this.filePaths.add(filePath);return filePath;} catch (error) {- this.cleanup(); // 写入失败时立即清理+ this.cleanup(); // Immediately cleanup on write failurethrow new Error(`Failed to write temp file: ${(error as Error).message}`);}}/**- * 安全清理临时资源+ * Safely cleanup temporary resources*/cleanup(): void {if (existsSync(this.tempDir)) {- // 递归删除目录及内容+ // Recursively delete directory and its contentsrmSync(this.tempDir, { force: true, recursive: true });this.filePaths.clear();}}/**- * 注册进程退出/异常时的自动清理+ * Register automatic cleanup on process exit/exception*/private registerCleanupHook(): void {- // 正常退出+ // Normal exitprocess.on('exit', () => this.cleanup());- // 异常退出+ // Exception exitprocess.on('uncaughtException', (err) => {console.error('Uncaught exception, cleaning temp files:', err);this.cleanup();process.exit(1);});- // 信号终止+ // Signal termination['SIGINT', 'SIGTERM'].forEach((signal) => {process.on(signal, () => {this.cleanup();