| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- # 清理旧版存储目录(Windows PowerShell)。确认新布局已经验证通过后再执行。
- # 用法:
- # powershell -ExecutionPolicy Bypass -File deploy/storage-legacy-clean.ps1
- # powershell -ExecutionPolicy Bypass -File deploy/storage-legacy-clean.ps1 -Confirm
- param(
- [switch]$Confirm
- )
- $ErrorActionPreference = "Stop"
- $Root = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
- $Base = Join-Path $Root "qingjian"
- $Targets = @(
- (Join-Path $Base "workspace"),
- (Join-Path $Base "chat-attachments"),
- (Join-Path $Base "agent"),
- (Join-Path $Base "tmp"),
- (Join-Path $Base "graph_his"),
- (Join-Path $Root ".agentscope"),
- (Join-Path $Root "data\files"),
- (Join-Path $Root "data\native"),
- (Join-Path $Root "ai-server\QingJian"),
- (Join-Path $Root "ai-server\data"),
- (Join-Path $Root "ai-server\.agentscope")
- )
- Write-Host "将清理以下旧目录:"
- foreach ($t in $Targets) {
- if (Test-Path $t) {
- $size = (Get-ChildItem -LiteralPath $t -Recurse -Force -ErrorAction SilentlyContinue |
- Measure-Object -Property Length -Sum).Sum
- $mb = if ($size) { [math]::Round($size / 1MB, 1) } else { 0 }
- Write-Host " - $t (${mb} MB)"
- }
- }
- if (-not $Confirm) {
- Write-Host ""
- Write-Host "未删除任何文件。确认无误后追加 -Confirm 执行。"
- exit 0
- }
- foreach ($t in $Targets) {
- if (Test-Path $t) {
- Write-Host "删除 $t"
- Remove-Item -LiteralPath $t -Recurse -Force
- }
- }
- Write-Host "清理完成。业务数据保留在 $Base\data"
|