Add comprehensive debugging to move functionality
This commit is contained in:
parent
83a5a734b8
commit
b4a23b5fd7
33
main.js
33
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
|
// IPC handler for searching TVDB
|
||||||
ipcMain.handle('search-tvdb', async (event, query) => {
|
ipcMain.handle('search-tvdb', async (event, query) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -290,23 +290,24 @@ function displayCreatedFolder(folderPath) {
|
|||||||
|
|
||||||
// Function to move tagged files to appropriate folders
|
// Function to move tagged files to appropriate folders
|
||||||
function moveTaggedFile(filePath, tagType) {
|
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
|
// Send request to main process to move the file
|
||||||
ipcRenderer.invoke('move-file-to-folder', {
|
ipcRenderer.invoke('move-file-to-folder', {
|
||||||
filePath: filePath,
|
filePath: filePath,
|
||||||
folderName: tagType
|
folderName: tagType
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
|
console.log(`[RENDERER] Move result:`, result);
|
||||||
if (result.success) {
|
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
|
// Show visual feedback that directory was created
|
||||||
showDirectoryFeedback(tagType);
|
showDirectoryFeedback(tagType);
|
||||||
} else {
|
} 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}`);
|
alert(`Failed to move file: ${result.error}`);
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error('Error moving file:', error);
|
console.error('[RENDERER] Error moving file:', error);
|
||||||
alert(`Error moving file: ${error.message}`);
|
alert(`Error moving file: ${error.message}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user