From 70273d37ce566282dfdea1125a1a4d327eca8d51 Mon Sep 17 00:00:00 2001 From: opencode Date: Sun, 5 Jul 2026 07:36:50 +0000 Subject: [PATCH] fix #10: replace sync fs calls with async in fileUtils.js --- utils/fileUtils.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/utils/fileUtils.js b/utils/fileUtils.js index 53c3b32..04685e5 100644 --- a/utils/fileUtils.js +++ b/utils/fileUtils.js @@ -23,7 +23,7 @@ function isMediaFile(filePath) { */ async function scanDirectory(directoryPath, progressCallback = null) { try { - const files = fs.readdirSync(directoryPath); + const files = await fs.promises.readdir(directoryPath); const items = []; // First pass: collect folders and media files to process @@ -36,7 +36,7 @@ async function scanDirectory(directoryPath, progressCallback = null) { const filePath = path.join(directoryPath, file); try { - const stat = fs.statSync(filePath); + const stat = await fs.promises.stat(filePath); if (stat.isDirectory()) { folders.push({ @@ -142,8 +142,7 @@ async function extractFileDuration(filePath) { console.warn(`ffprobe error for ${filePath}:`, err.message); // Try alternative approach - attempt to get duration from file stats or use fallback try { - const fs = require('fs'); - const stats = fs.statSync(filePath); + const stats = await fs.promises.stat(filePath); console.log(`File size for ${filePath}: ${stats.size} bytes`); // For now, return 00:00 as fallback for problematic files resolve({ duration: '00:00', isProblematic: true });