fix: 调整 NAS 部署配置与脚本清理逻辑

This commit is contained in:
wkc
2026-03-16 14:54:42 +08:00
parent 7a5ae3f1cc
commit 0c2d738cfe
5 changed files with 31 additions and 4 deletions

View File

@@ -33,7 +33,18 @@ function Ensure-Command {
function Reset-Directory {
param([string]$Path)
if (Test-Path $Path) {
[System.IO.Directory]::Delete($Path, $true)
Get-ChildItem -LiteralPath $Path -Recurse -Force -ErrorAction SilentlyContinue | ForEach-Object {
$_.Attributes = $_.Attributes `
-band (-bnot [System.IO.FileAttributes]::ReadOnly) `
-band (-bnot [System.IO.FileAttributes]::Hidden) `
-band (-bnot [System.IO.FileAttributes]::System)
}
$rootItem = Get-Item -LiteralPath $Path -Force
$rootItem.Attributes = $rootItem.Attributes `
-band (-bnot [System.IO.FileAttributes]::ReadOnly) `
-band (-bnot [System.IO.FileAttributes]::Hidden) `
-band (-bnot [System.IO.FileAttributes]::System)
Remove-Item -LiteralPath $Path -Recurse -Force
}
New-Item -ItemType Directory -Path $Path | Out-Null
}