File size: 1,892 Bytes
28e1dba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import huggingfaceStorageService from './src/services/huggingfaceStorageService.js';

// 简单测试Huggingface环境修复
async function testSimpleFix() {
  console.log('🧪 Testing Huggingface storage fix...');
  
  try {
    // 测试存储服务初始化
    console.log('\n📁 Testing storage service initialization...');
    await huggingfaceStorageService.initialize();
    console.log('✅ Storage service initialized successfully');
    console.log(`📁 Data directory: ${huggingfaceStorageService.dataDir}`);
    
    // 测试目录创建
    console.log('\n📂 Testing directory creation...');
    const testUserId = 'PS02';
    const testPptId = 'test-ppt-' + Date.now();
    
    try {
      await huggingfaceStorageService.storePPTData(testUserId, testPptId, {
        title: 'Test PPT for Huggingface',
        slides: [{
          id: 'slide1',
          elements: [{
            type: 'text',
            content: 'Hello Huggingface!'
          }]
        }]
      });
      console.log('✅ PPT data storage test passed - no permission errors!');
      
      // 测试数据读取
      const storedData = await huggingfaceStorageService.getPPTData(testUserId, testPptId);
      if (storedData && storedData.title === 'Test PPT for Huggingface') {
        console.log('✅ PPT data retrieval test passed!');
      } else {
        console.log('⚠️ PPT data retrieval test failed');
      }
      
    } catch (storageError) {
      console.error('❌ PPT data storage test failed:', storageError.message);
      if (storageError.code === 'EACCES') {
        console.error('🚨 Permission denied error - the fix may not be working in production');
      }
    }
    
    console.log('\n🎉 Core storage tests completed!');
    
  } catch (error) {
    console.error('❌ Test failed:', error.message);
  }
}

// 运行测试
testSimpleFix().catch(console.error);