diff --git a/main.js b/main.js index 47655a2..2aca8bc 100644 --- a/main.js +++ b/main.js @@ -120,13 +120,28 @@ ipcMain.handle('rename-file', async (event, { oldPath, newName }) => { // Create log file for debugging const fs = require('fs'); +const path = require('path'); + +// Ensure log file exists at startup +const logFilePath = path.join(__dirname, 'app-debug.log'); +try { + // Try to create or truncate the log file + fs.writeFileSync(logFilePath, `=== Application started at ${new Date().toISOString()} ===\n`); + console.log('Debug log file created successfully at:', logFilePath); +} catch (error) { + console.error('Failed to create debug log file:', error.message); + throw new Error('Cannot create debug log file - check permissions'); +} -const logFilePath = __dirname + '/file-move-debug.log'; function writeLog(message) { const timestamp = new Date().toISOString(); const logEntry = `[${timestamp}] ${message}\n`; - fs.appendFileSync(logFilePath, logEntry); - console.log(logEntry.trim()); + try { + fs.appendFileSync(logFilePath, logEntry); + console.log(logEntry.trim()); + } catch (error) { + console.error('Failed to write to log file:', error.message); + } } // IPC handler for moving file to folder