voice-changer: upgrade cleanup deletes only files shipped by earlier builds
secure-dir.ps1 Prepare used to delete every root file (and whole scripts/app/launcher/uninstall
dirs) when upgrading. It now removes only the named files of earlier distributions (plus the
uninstall logs, which run elevated) and empty dirs; any other file stays and is only re-owned
by Administrators with inherited permissions.
Windows 11 VM: 21b4278 install + root sample.wav, models\keep.wav, scripts\note.txt ->
upgrade -> SHA256 unchanged for all three (also after silent uninstall).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -67,16 +67,31 @@ if ($Mode -eq 'Prepare') {
|
||||
if ($link) { Say "링크 발견: $link"; exit 11 }
|
||||
}
|
||||
if ($upgrade) {
|
||||
# 이전 버전(21b4278)은 설치 폴더 전체를 사용자 쓰기로 두었다. 관리자 권한으로 실행되는 부분(스크립트 · 앱 코드 ·
|
||||
# 제거 프로그램과 그 기록 · 실행기)은 믿지 않고 지운 뒤 새로 푼다. apo\ 는 원래 마이크 설정 백업만 남긴다(mic-apo.ps1 이 검증).
|
||||
foreach ($d in 'scripts', 'app', 'launcher', 'uninstall') {
|
||||
$p = Join-Path $App $d
|
||||
if (Test-Path -LiteralPath $p) { Remove-Item -LiteralPath $p -Recurse -Force }
|
||||
# 이전 버전(21b4278)은 설치 폴더 전체를 사용자 쓰기로 두었다. 이전 배포에 들어 있던 실행 부분은 믿지 않고
|
||||
# 이름을 하나씩 지정해서만 지운다 (새 파일은 곧 다시 풂). 목록에 없는 파일(사용자가 넣어 둔 녹음 등)은 지우지 않고,
|
||||
# 아래에서 소유자 · 권한만 관리자 쪽으로 정리한다. 제거 기록(unins*.dat)은 제거할 때 관리자 권한으로 쓰이므로 꼭 지운다.
|
||||
$known = [ordered]@{
|
||||
'.' = @('VoiceChanger.exe', 'install.bat', 'train.bat', 'examples.bat', 'README.md')
|
||||
'scripts' = @('install.ps1', 'mic-apo.ps1')
|
||||
'app' = @('common.py', 'examples.py', 'mic_bridge.py', 'models.py', 'setup_engine.py', 'train.py', 'voice_changer.py')
|
||||
'launcher' = @('launcher.c')
|
||||
'apo' = @('VoiceChangerAPO.dll', 'vcapo.cpp', 'vccore.h', 'vcapo.def', 'mic-apo.json', 'mic-apo.log')
|
||||
'uninstall' = @('unins*.exe', 'unins*.dat', 'unins*.msg')
|
||||
'app\__pycache__' = @('*.pyc')
|
||||
}
|
||||
Get-ChildItem -LiteralPath $App -Force -File | Remove-Item -Force
|
||||
$apo = Join-Path $App 'apo'
|
||||
if (Test-Path -LiteralPath $apo) { Get-ChildItem -LiteralPath $apo -Force | ? { $_.Name -ne 'mic-apo-backup.json' } | Remove-Item -Recurse -Force }
|
||||
Say "업데이트: 이전 실행 파일 정리"
|
||||
$n = 0
|
||||
foreach ($d in $known.Keys) {
|
||||
$dir = if ($d -eq '.') { $App } else { Join-Path $App $d }
|
||||
if (-not (Test-Path -LiteralPath $dir -PathType Container)) { continue }
|
||||
foreach ($pat in $known[$d]) {
|
||||
Get-ChildItem -LiteralPath $dir -Force -File -Filter $pat | ForEach-Object { Remove-Item -LiteralPath $_.FullName -Force; $n++ }
|
||||
}
|
||||
}
|
||||
foreach ($d in 'app\__pycache__', 'app', 'scripts', 'launcher', 'uninstall') { # 비었을 때만
|
||||
$dir = Join-Path $App $d
|
||||
if ((Test-Path -LiteralPath $dir) -and -not [IO.Directory]::EnumerateFileSystemEntries($dir).GetEnumerator().MoveNext()) { Remove-Item -LiteralPath $dir -Force }
|
||||
}
|
||||
Say "업데이트: 이전 배포 파일 $n 개 정리 (그 밖의 파일은 남김)"
|
||||
}
|
||||
New-Item -ItemType Directory -Force -Path $App | Out-Null
|
||||
$sd = New-Object System.Security.AccessControl.DirectorySecurity
|
||||
|
||||
Reference in New Issue
Block a user