- Fix WebDAV service to find all 4,101 MP3 files instead of 1,023 - Add support for AIFF files (.aif, .aiff) in audio detection - Update audioMetadataService to recognize AIFF formats - Simplify BackgroundJobProgress component polling logic - Add maxDepth parameter to WebDAV directory listing - Add comprehensive test scripts for debugging WebDAV integration The WebDAV integration now correctly processes all 4,257 audio files from the music collection, including 4,101 MP3 files and 156 other audio formats (FLAC, WAV, AIFF, M4A, OGG).
123 lines
4.3 KiB
JavaScript
123 lines
4.3 KiB
JavaScript
import { createClient } from 'webdav';
|
|
import fs from 'fs';
|
|
|
|
async function debugWebDAVFiles() {
|
|
try {
|
|
// Load configuration
|
|
const configData = fs.readFileSync('storage-config.json', 'utf-8');
|
|
const config = JSON.parse(configData);
|
|
|
|
console.log('🔍 WebDAV Configuration:');
|
|
console.log('URL:', config.url);
|
|
console.log('Username:', config.username);
|
|
console.log('Base Path:', config.basePath);
|
|
console.log('');
|
|
|
|
// Create WebDAV client
|
|
const client = createClient(config.url, {
|
|
username: config.username,
|
|
password: config.password,
|
|
});
|
|
|
|
console.log('🔗 Testing connection...');
|
|
const basePath = config.basePath || '/Music';
|
|
|
|
try {
|
|
const baseContents = await client.getDirectoryContents(basePath);
|
|
console.log('✅ Connection successful');
|
|
console.log('Base directory contents count:', Array.isArray(baseContents) ? baseContents.length : 1);
|
|
console.log('');
|
|
|
|
// Test deep listing
|
|
console.log('📁 Testing deep directory listing...');
|
|
const deepContents = await client.getDirectoryContents(basePath, { deep: true });
|
|
|
|
console.log('Deep listing response type:', typeof deepContents);
|
|
console.log('Is array:', Array.isArray(deepContents));
|
|
|
|
if (Array.isArray(deepContents)) {
|
|
console.log('Total items found:', deepContents.length);
|
|
|
|
// Count files vs directories
|
|
let fileCount = 0;
|
|
let dirCount = 0;
|
|
const fileExtensions = new Map();
|
|
const directories = new Set();
|
|
|
|
for (const item of deepContents) {
|
|
if (item && typeof item === 'object' && 'type' in item) {
|
|
if (item.type === 'file') {
|
|
fileCount++;
|
|
|
|
// Track file extensions
|
|
const ext = item.basename?.split('.').pop()?.toLowerCase() || 'unknown';
|
|
fileExtensions.set(ext, (fileExtensions.get(ext) || 0) + 1);
|
|
} else if (item.type === 'directory') {
|
|
dirCount++;
|
|
const relativePath = item.filename.replace(basePath + '/', '');
|
|
if (relativePath) {
|
|
directories.add(relativePath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log('📊 File Statistics:');
|
|
console.log('Files:', fileCount);
|
|
console.log('Directories:', dirCount);
|
|
console.log('Total items:', fileCount + dirCount);
|
|
console.log('');
|
|
|
|
console.log('📁 Directory structure (first 20):');
|
|
const sortedDirs = Array.from(directories).sort();
|
|
sortedDirs.slice(0, 20).forEach(dir => {
|
|
console.log(' 📁', dir);
|
|
});
|
|
if (sortedDirs.length > 20) {
|
|
console.log(` ... and ${sortedDirs.length - 20} more directories`);
|
|
}
|
|
console.log('');
|
|
|
|
console.log('🎵 File extensions:');
|
|
const sortedExts = Array.from(fileExtensions.entries()).sort((a, b) => b[1] - a[1]);
|
|
sortedExts.forEach(([ext, count]) => {
|
|
console.log(` .${ext}: ${count} files`);
|
|
});
|
|
console.log('');
|
|
|
|
// Show some sample files
|
|
console.log('🎵 Sample files (first 10):');
|
|
const sampleFiles = deepContents
|
|
.filter(item => item && typeof item === 'object' && 'type' in item && item.type === 'file')
|
|
.slice(0, 10);
|
|
|
|
sampleFiles.forEach((file, index) => {
|
|
const relativePath = file.filename.replace(basePath + '/', '');
|
|
console.log(` ${index + 1}. ${relativePath} (${file.size} bytes)`);
|
|
});
|
|
|
|
if (fileCount > 10) {
|
|
console.log(` ... and ${fileCount - 10} more files`);
|
|
}
|
|
|
|
} else {
|
|
console.log('❌ Deep listing returned non-array response:', deepContents);
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('❌ Error during WebDAV operations:', error);
|
|
console.error('Error details:', error.message);
|
|
if (error.response) {
|
|
console.error('Response status:', error.response.status);
|
|
console.error('Response data:', error.response.data);
|
|
}
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('❌ Failed to load configuration or create client:', error);
|
|
}
|
|
}
|
|
|
|
// Run the debug function
|
|
debugWebDAVFiles().catch(console.error);
|