zhangfeng 3 tháng trước cách đây
mục cha
commit
c476e7d8e3
1 tập tin đã thay đổi với 3 bổ sung0 xóa
  1. 3 0
      src/hooks/image-hook.ts

+ 3 - 0
src/hooks/image-hook.ts

@@ -73,6 +73,9 @@ function sanitizeFilename(name: string): string {
 
 function cleanupOldImages(dir: string, saveDir: string): void {
   const now = Date.now();
+  if (!lastCleanupByDir.has(dir) && existsSync(dir)) {
+    lastCleanupByDir.set(dir, now);
+  }
   const lastCleanup = lastCleanupByDir.get(dir) ?? 0;
   if (now - lastCleanup < CLEANUP_INTERVAL) return;
   lastCleanupByDir.set(dir, now);