Add comprehensive debugging to move functionality

This commit is contained in:
Jarian Cottingham 2026-02-21 15:53:45 -06:00
parent 83a5a734b8
commit b4a23b5fd7
2 changed files with 38 additions and 4 deletions

33
main.js
View File

@ -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 {

View File

@ -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}`);
});
}