# 检查生产服务器 uploads 目录中的视频文件 # 查找缺失的 110 条视频文件是否在生产服务器上 param( [string]$ServerIP = '192.168.58.20', [string]$ServerUser = 'root', [string]$UploadsPath = '/mnt/PoolOne/apps/youyidian-3d/uploads' ) Write-Host "==== 检查生产服务器 uploads 目录 ====" -ForegroundColor Cyan Write-Host "服务器: $ServerIP" -ForegroundColor Yellow Write-Host "路径: $UploadsPath" -ForegroundColor Yellow Write-Host "" # 1. 检查目录是否存在 Write-Host "1. 检查目录是否存在..." -ForegroundColor Cyan $checkDirCmd = "test -d '$UploadsPath' && echo 'EXISTS' || echo 'NOT_EXISTS'" $dirExists = ssh "${ServerUser}@${ServerIP}" $checkDirCmd if ($dirExists -match 'NOT_EXISTS') { Write-Host "❌ 目录不存在: $UploadsPath" -ForegroundColor Red Write-Host "尝试检查其他可能的路径..." -ForegroundColor Yellow # 尝试其他可能的路径 $possiblePaths = @( '/app/uploads', './uploads', '/mnt/tank/uploads', '/mnt/PoolOne/uploads' ) foreach ($path in $possiblePaths) { $checkCmd = "test -d '$path' && echo 'EXISTS' || echo 'NOT_EXISTS'" $result = ssh "${ServerUser}@${ServerIP}" $checkCmd if ($result -match 'EXISTS') { Write-Host "✅ 找到目录: $path" -ForegroundColor Green $UploadsPath = $path break } } if ($UploadsPath -eq '/mnt/PoolOne/apps/youyidian-3d/uploads' -and $dirExists -match 'NOT_EXISTS') { Write-Host "❌ 无法找到 uploads 目录" -ForegroundColor Red exit 1 } } else { Write-Host "✅ 目录存在: $UploadsPath" -ForegroundColor Green } Write-Host "" # 2. 统计 video-*.mp4 文件数量 Write-Host "2. 统计 video-*.mp4 文件..." -ForegroundColor Cyan $countCmd = "find '$UploadsPath' -name 'video-*.mp4' -type f 2>/dev/null | wc -l" $fileCount = ssh "${ServerUser}@${ServerIP}" $countCmd Write-Host "找到 $fileCount 个 video-*.mp4 文件" -ForegroundColor Yellow # 3. 列出前 20 个文件 Write-Host "" Write-Host "3. 列出前 20 个 video-*.mp4 文件..." -ForegroundColor Cyan $listCmd = "find '$UploadsPath' -name 'video-*.mp4' -type f 2>/dev/null | head -20 | xargs -I {} basename {}" $files = ssh "${ServerUser}@${ServerIP}" $listCmd Write-Host $files # 4. 检查是否有 video-source-*.mp4 文件 Write-Host "" Write-Host "4. 检查 video-source-*.mp4 文件..." -ForegroundColor Cyan $countSourceCmd = "find '$UploadsPath' -name 'video-source-*.mp4' -type f 2>/dev/null | wc -l" $sourceFileCount = ssh "${ServerUser}@${ServerIP}" $countSourceCmd Write-Host "找到 $sourceFileCount 个 video-source-*.mp4 文件" -ForegroundColor Yellow if ([int]$sourceFileCount -gt 0) { Write-Host "" Write-Host "前 10 个 video-source-*.mp4 文件:" -ForegroundColor Yellow $listSourceCmd = "find '$UploadsPath' -name 'video-source-*.mp4' -type f 2>/dev/null | head -10 | xargs -I {} basename {}" $sourceFiles = ssh "${ServerUser}@${ServerIP}" $listSourceCmd Write-Host $sourceFiles } # 5. 检查特定文件是否存在(从数据库中查询缺失的文件) Write-Host "" Write-Host "5. 检查数据库中缺失的文件是否在生产服务器上..." -ForegroundColor Cyan $missingFileList = "missing-video-files.txt" if (Test-Path $missingFileList) { Write-Host "读取文件列表: $missingFileList" -ForegroundColor Yellow $files = Get-Content $missingFileList Write-Host "共 $($files.Count) 个文件需要检查" -ForegroundColor Yellow Write-Host "检查前 10 个文件..." -ForegroundColor Yellow Write-Host "" $foundCount = 0 $notFoundCount = 0 foreach ($fileName in $files[0..9]) { $checkCmd = "test -f '$UploadsPath/$fileName' && echo 'EXISTS' || echo 'NOT_EXISTS'" $result = ssh "${ServerUser}@${ServerIP}" $checkCmd if ($result -match 'EXISTS') { Write-Host "✅ $fileName" -ForegroundColor Green $foundCount++ } else { Write-Host "❌ $fileName" -ForegroundColor Red $notFoundCount++ } } Write-Host "" Write-Host "检查结果(前 10 个):" -ForegroundColor Cyan Write-Host " 找到: $foundCount 个" -ForegroundColor Green Write-Host " 未找到: $notFoundCount 个" -ForegroundColor Red Write-Host " 还有 $($files.Count - 10) 个文件待检查" -ForegroundColor Yellow } else { Write-Host "⚠️ 文件列表不存在: $missingFileList" -ForegroundColor Yellow Write-Host " 请先运行: npx ts-node --transpile-only scripts/generate-missing-file-list.ts" -ForegroundColor Yellow } Write-Host "" Write-Host "==== 检查完成 ====" -ForegroundColor Cyan Write-Host "" Write-Host "💡 建议:" -ForegroundColor Yellow Write-Host " 1. 如果文件在生产服务器上,可以同步到本地" -ForegroundColor White Write-Host " 2. 如果文件不在生产服务器上,可能是历史数据,文件已被删除" -ForegroundColor White Write-Host " 3. 可以运行完整检查:检查所有 110 个文件" -ForegroundColor White