const DatabaseHelper = require('./database/db-helper'); const fs = require('fs'); const path = require('path'); async function debugFiles() { const db = new DatabaseHelper(); try { await db.connect(); console.log('\n๐Ÿ“‹ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ๋ชจ๋“  ํŒŒ์ผ:'); const files = await db.getAllFiles(); files.forEach((file, index) => { console.log(`\n${index + 1}. ${file.title} (ID: ${file.id})`); console.log(` ์นดํ…Œ๊ณ ๋ฆฌ: ${file.category}`); console.log(` ์ฒจ๋ถ€ํŒŒ์ผ: ${file.files?.length || 0}๊ฐœ`); if (file.files && file.files.length > 0) { file.files.forEach((attachment, idx) => { console.log(` ${idx + 1}) ${attachment.original_name}`); console.log(` - ID: ${attachment.id}`); console.log(` - ๊ฒฝ๋กœ: ${attachment.file_path}`); console.log(` - ํŒŒ์ผ๋ช…: ${attachment.file_name}`); console.log(` - ํฌ๊ธฐ: ${attachment.file_size}`); // ์‹ค์ œ ํŒŒ์ผ ์กด์žฌ ํ™•์ธ const fullPath = path.join(__dirname, attachment.file_path); const exists = fs.existsSync(fullPath); console.log(` - ์‹ค์ œ ํŒŒ์ผ ์กด์žฌ: ${exists ? 'โœ…' : 'โŒ'} (${fullPath})`); if (!exists) { // ๋‹ค๋ฅธ ๊ฒฝ๋กœ๋“ค ์‹œ๋„ const paths = [ path.join(__dirname, 'uploads', attachment.file_name), path.join(__dirname, 'uploads', attachment.original_name), attachment.file_path, ]; console.log(` - ์‹œ๋„ํ•  ๊ฒฝ๋กœ๋“ค:`); paths.forEach(p => { const pathExists = fs.existsSync(p); console.log(` ${pathExists ? 'โœ…' : 'โŒ'} ${p}`); }); } }); } }); console.log('\n๐Ÿ“ uploads ํด๋”์˜ ์‹ค์ œ ํŒŒ์ผ๋“ค:'); const uploadsDir = path.join(__dirname, 'uploads'); if (fs.existsSync(uploadsDir)) { const actualFiles = fs.readdirSync(uploadsDir); actualFiles.forEach(file => { const filePath = path.join(uploadsDir, file); const stats = fs.statSync(filePath); console.log(` - ${file} (ํฌ๊ธฐ: ${stats.size})`); }); } } catch (error) { console.error('โŒ ์˜ค๋ฅ˜:', error.message); } finally { await db.close(); } } debugFiles();