Add enhanced debugging for directory persistence investigation

- Added detailed error logging in refreshAllDirectories with full directory paths
- Keep inaccessible directories in list instead of removing them
- Enhanced porn-cinema.html to show actual directory data from storage
- Log directory refresh process step by step to identify where directories disappear
- Should reveal why linked directories become 0 after refresh
This commit is contained in:
dilgenfritz 2025-11-03 17:18:17 -06:00
parent a9a1c9e4a1
commit 04c5a496ae
2 changed files with 23 additions and 3 deletions

View File

@ -280,7 +280,11 @@
try {
// First check what's currently in localStorage
const storedData = localStorage.getItem('linkedVideoDirectories');
console.log('📁 Stored directory data:', storedData ? JSON.parse(storedData) : 'None');
const parsedData = storedData ? JSON.parse(storedData) : null;
console.log('📁 Stored directory data:', parsedData);
if (parsedData && parsedData.directories) {
console.log('📁 Directory list from storage:', parsedData.directories.map(d => ({ name: d.name, path: d.path })));
}
// Force reload from storage first
await window.desktopFileManager.loadLinkedDirectories();

View File

@ -441,7 +441,7 @@ class DesktopFileManager {
for (const directory of this.externalVideoDirectories) {
try {
console.log(`🔍 Rescanning: ${directory.name}`);
console.log(`🔍 Rescanning: ${directory.name} at ${directory.path}`);
const videoFiles = await window.electronAPI.readVideoDirectoryRecursive(directory.path);
const linkedVideos = videoFiles.map(video => ({
@ -465,8 +465,13 @@ class DesktopFileManager {
console.log(`✅ Found ${videoFiles.length} videos in ${directory.name}`);
} catch (error) {
console.warn(`Could not access directory ${directory.name}:`, error);
console.error(`❌ Could not access directory ${directory.name} at ${directory.path}:`, error);
console.error(`❌ Directory will be marked as inaccessible but kept in list`);
// Directory might be unavailable (external drive, network, etc.)
// Don't remove it from the list, just mark it as having 0 videos
directory.videoCount = 0;
directory.lastError = error.message;
directory.lastErrorTime = new Date().toISOString();
}
}
@ -500,8 +505,19 @@ class DesktopFileManager {
console.log(`📁 Loaded ${this.externalVideoDirectories.length} linked directories from storage`);
console.log('📁 Directory details:', this.externalVideoDirectories.map(d => ({ name: d.name, path: d.path, id: d.id })));
// Log what we're about to refresh
console.log(`🔄 About to refresh ${this.externalVideoDirectories.length} directories...`);
for (const dir of this.externalVideoDirectories) {
console.log(` 📁 ${dir.name}: ${dir.path}`);
}
// Refresh all directories to get current video lists
await this.refreshAllDirectories();
// Log final state after refresh
console.log(`📁 After refresh: ${this.externalVideoDirectories.length} directories, ${this.allLinkedVideos.length} videos`);
} else {
console.log('📁 No stored directories found');
}
} catch (error) {
console.error('Error loading linked directories:', error);