Browse Source

Merge pull request #346 from zuuky/fix/issue-345

fix: #345
Alvin 3 months ago
parent
commit
bd55eda341
1 changed files with 3 additions and 0 deletions
  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);