rekordbox-viewer/packages/backend/test-s3-service.js
Geert Rademakes 3cd83ff2b5 feat: improve S3 sync and song matching with better FLAC support, NaN validation, and enhanced logging
- Enhanced AudioMetadataService with comprehensive NaN handling for all numeric fields
- Added validation for year, duration, bitrate, sampleRate, and channels
- Improved FLAC format detection and error handling with fallback support
- Added detailed logging for S3 sync process with progress tracking and file statistics
- Enhanced song matching service with progress indicators and confidence scoring
- Added comprehensive logging for auto-match and link operations
- Improved error handling and graceful degradation for metadata extraction
- Added test scripts for metadata service validation
- Updated S3 service to use configuration from s3-config.json file
- Added automatic S3 service reload when configuration is updated

The S3 importer now provides much better visibility into file processing
and song matching operations, making it easier to debug issues and
monitor performance. FLAC files are properly handled and invalid
metadata values are filtered out to prevent database corruption.
2025-08-07 17:14:57 +02:00

42 lines
1.6 KiB
JavaScript

import { S3Service } from './src/services/s3Service.js';
async function testS3ServiceConfig() {
try {
console.log('🧪 Testing S3Service configuration loading...');
// Test loading configuration from file
const config = await S3Service.loadConfig();
console.log('✅ Configuration loaded from s3-config.json:');
console.log(` Endpoint: ${config.endpoint}`);
console.log(` Region: ${config.region}`);
console.log(` Bucket: ${config.bucketName}`);
console.log(` UseSSL: ${config.useSSL}`);
console.log(` AccessKeyId: ${config.accessKeyId ? '***' : 'not set'}`);
console.log(` SecretAccessKey: ${config.secretAccessKey ? '***' : 'not set'}`);
// Test creating S3Service instance
const s3Service = await S3Service.createFromConfig();
console.log('✅ S3Service instance created successfully');
// Test listing files (this will verify the connection works)
console.log('📁 Testing file listing...');
const files = await s3Service.listAllFiles();
console.log(`✅ Found ${files.length} files in bucket`);
if (files.length > 0) {
console.log(' Sample files:');
files.slice(0, 3).forEach(file => {
console.log(` - ${file.key} (${file.size} bytes)`);
});
}
console.log('\n🎉 S3Service configuration test passed!');
console.log(' The S3 sync is now using the correct configuration from s3-config.json');
} catch (error) {
console.error('❌ S3Service configuration test failed:', error.message);
console.log('\n💡 This means the S3 sync will fall back to environment variables');
}
}
testS3ServiceConfig();