diff --git a/main.js b/main.js index 9b81f53..5c761cc 100644 --- a/main.js +++ b/main.js @@ -178,6 +178,39 @@ ipcMain.handle('move-file-to-folder', async (event, { filePath, folderName }) => } }); +// Function to test moving files (for debugging purposes) +function testMoveFunction() { + // This is for testing the function directly from main process + console.log('Testing move function directly...'); + + const fs = require('fs'); + const path = require('path'); + + const testDir = path.join(__dirname, 'test_debug'); + const testFilePath = path.join(testDir, 'test_video.mp4'); + + // Clean up test dir + if (fs.existsSync(testDir)) { + fs.rmSync(testDir, { recursive: true }); + } + + // Create test dir and file + fs.mkdirSync(testDir, { recursive: true }); + fs.writeFileSync(testFilePath, 'test content'); + + console.log('Created test file:', testFilePath); + + // Test moving to extra + const targetFolder = path.join(testDir, 'extra'); + fs.mkdirSync(targetFolder, { recursive: true }); + + const newFilePath = path.join(targetFolder, 'test_video.mp4'); + fs.renameSync(testFilePath, newFilePath); + + console.log('Test move completed successfully'); + console.log('File now at:', newFilePath); +} + // IPC handler for searching TVDB ipcMain.handle('search-tvdb', async (event, query) => { try { diff --git a/renderer.js b/renderer.js index 18b70a5..4a4aa7d 100644 --- a/renderer.js +++ b/renderer.js @@ -290,23 +290,24 @@ function displayCreatedFolder(folderPath) { // Function to move tagged files to appropriate folders function moveTaggedFile(filePath, tagType) { - console.log(`Moving file ${filePath} to ${tagType} folder`); + console.log(`[RENDERER] Moving file ${filePath} to ${tagType} folder`); // Send request to main process to move the file ipcRenderer.invoke('move-file-to-folder', { filePath: filePath, folderName: tagType }).then(result => { + console.log(`[RENDERER] Move result:`, result); if (result.success) { - console.log(`File moved successfully to ${tagType} folder`); + console.log(`[RENDERER] File moved successfully to ${tagType} folder`); // Show visual feedback that directory was created showDirectoryFeedback(tagType); } else { - console.error(`Failed to move file: ${result.error}`); + console.error(`[RENDERER] Failed to move file: ${result.error}`); alert(`Failed to move file: ${result.error}`); } }).catch(error => { - console.error('Error moving file:', error); + console.error('[RENDERER] Error moving file:', error); alert(`Error moving file: ${error.message}`); }); }