Skip to content

Commit

Permalink
scoop-cleanup: handle with junction better (#2882)
Browse files Browse the repository at this point in the history
* scoop-cleanup: handle with junction better

* scoop-cleanup: only resolve directory symbolic link

* scoop-cleanup: stop removing when an error occurs.
  • Loading branch information
chawyehsu authored and rasa committed Dec 14, 2018
1 parent 000f1a7 commit e4e76d3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions libexec/scoop-cleanup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@ function cleanup($app, $global, $verbose) {
$dir = versiondir $app $version $global
Get-ChildItem $dir | ForEach-Object {
$file = $_
if($null -ne $file.LinkType) {
fsutil.exe reparsepoint delete $file.FullName | out-null
# the file is a junction
if ($null -ne $file.LinkType -and $file -is [System.IO.DirectoryInfo]) {
# remove read-only attribute on the link
attrib -R /L $file
# remove the junction
$filepath = Resolve-Path $file
& "$env:COMSPEC" /c "rmdir /s /q $filepath"
}
}
Remove-Item $dir -Recurse -Force
Remove-Item $dir -ErrorAction Stop -Recurse -Force
}
write-host ''
}
Expand Down

0 comments on commit e4e76d3

Please sign in to comment.