Import the wilm agent store, WINC adoption work and batches CLI, with four fixes
This commit is contained in:
@@ -85,27 +85,27 @@ function Clear-InterruptedRun {
|
||||
}
|
||||
}
|
||||
|
||||
# A directory that exists but has no valid .git is a broken/partial clone -
|
||||
# USUALLY. It is also what -TargetDir pointed at somebody's Documents folder
|
||||
# looks like, and this ran Remove-Item -Recurse -Force on it without asking.
|
||||
# For a script distributed as "save it anywhere and run it", a mistyped
|
||||
# -TargetDir must not be able to delete a user's files.
|
||||
#
|
||||
# Only reclaim a directory this script can show it owns: empty, or carrying
|
||||
# the marker written after a successful clone. Anything else stops.
|
||||
if ((Test-Path $Target) -and -not (Test-Path (Join-Path $Target '.git'))) {
|
||||
$ours = Test-Path (Join-Path $Target $script:CloneMarker)
|
||||
$empty = -not (Get-ChildItem -LiteralPath $Target -Force |
|
||||
Select-Object -First 1)
|
||||
if ($ours -or $empty) {
|
||||
Write-Host "==> Removing incomplete clone at $Target" -ForegroundColor Cyan
|
||||
Remove-Item -Path $Target -Recurse -Force
|
||||
}
|
||||
else {
|
||||
throw ("$Target already exists, is not empty, and was not created " +
|
||||
"by this launcher. Refusing to delete it. Pass -TargetDir " +
|
||||
'pointing somewhere else, or remove it yourself if you are sure.')
|
||||
}
|
||||
# A directory that exists but has no valid .git is a broken/partial clone -
|
||||
# USUALLY. It is also what -TargetDir pointed at somebody's Documents folder
|
||||
# looks like, and this ran Remove-Item -Recurse -Force on it without asking.
|
||||
# For a script distributed as "save it anywhere and run it", a mistyped
|
||||
# -TargetDir must not be able to delete a user's files.
|
||||
#
|
||||
# Only reclaim a directory this script can show it owns: empty, or carrying
|
||||
# the marker written after a successful clone. Anything else stops.
|
||||
if ((Test-Path $Target) -and -not (Test-Path (Join-Path $Target '.git'))) {
|
||||
$ours = Test-Path (Join-Path $Target $script:CloneMarker)
|
||||
$empty = -not (Get-ChildItem -LiteralPath $Target -Force |
|
||||
Select-Object -First 1)
|
||||
if ($ours -or $empty) {
|
||||
Write-Host "==> Removing incomplete clone at $Target" -ForegroundColor Cyan
|
||||
Remove-Item -Path $Target -Recurse -Force
|
||||
}
|
||||
else {
|
||||
throw ("$Target already exists, is not empty, and was not created " +
|
||||
"by this launcher. Refusing to delete it. Pass -TargetDir " +
|
||||
'pointing somewhere else, or remove it yourself if you are sure.')
|
||||
}
|
||||
}
|
||||
|
||||
# A clone created by an elevated (Administrator) run is owned by
|
||||
|
||||
Reference in New Issue
Block a user