Skip to content

Commit 4a9efaa

Browse files
authored
fix(current): Remove 'current' while it's not a junction (#4687)
1 parent 98ea7a5 commit 4a9efaa

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
- **autoupdate:** Allow checksum file that contains whitespaces ([#4619](https://github.com/ScoopInstaller/Scoop/issues/4619))
1212
- **config:** Allow scoop config use Unicode characters ([#4631](https://github.com/ScoopInstaller/Scoop/issues/4631))
13+
- **current:** Remove 'current' while it's not a junction ([#4687](https://github.com/ScoopInstaller/Scoop/issues/4687))
1314
- **depends:** Prevent error on no URL ([#4595](https://github.com/ScoopInstaller/Scoop/issues/4595))
1415
- **depends:** Check if extractor is available ([#4042](https://github.com/ScoopInstaller/Scoop/issues/4042))
1516
- **decompress:** Fix nested Zstd archive extraction ([#4608](https://github.com/ScoopInstaller/Scoop/issues/4608))

lib/install.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -911,20 +911,20 @@ function current_dir($versiondir) {
911911
# Returns the 'current' junction directory if in use, otherwise
912912
# the version directory.
913913
function link_current($versiondir) {
914-
if(get_config NO_JUNCTIONS) { return $versiondir }
914+
if (get_config NO_JUNCTIONS) { return $versiondir }
915915

916916
$currentdir = current_dir $versiondir
917917

918-
write-host "Linking $(friendly_path $currentdir) => $(friendly_path $versiondir)"
918+
Write-Host "Linking $(friendly_path $currentdir) => $(friendly_path $versiondir)"
919919

920-
if($currentdir -eq $versiondir) {
920+
if ($currentdir -eq $versiondir) {
921921
abort "Error: Version 'current' is not allowed!"
922922
}
923923

924-
if(test-path $currentdir) {
924+
if (Test-Path $currentdir) {
925925
# remove the junction
926926
attrib -R /L $currentdir
927-
& "$env:COMSPEC" /c rmdir $currentdir
927+
Remove-Item $currentdir -Recurse -Force -ErrorAction Stop
928928
}
929929

930930
New-Item -Path $currentdir -ItemType Junction -Value $versiondir | Out-Null
@@ -938,17 +938,17 @@ function link_current($versiondir) {
938938
# Returns the 'current' junction directory (if it exists),
939939
# otherwise the normal version directory.
940940
function unlink_current($versiondir) {
941-
if(get_config NO_JUNCTIONS) { return $versiondir }
941+
if (get_config NO_JUNCTIONS) { return $versiondir }
942942
$currentdir = current_dir $versiondir
943943

944-
if(test-path $currentdir) {
945-
write-host "Unlinking $(friendly_path $currentdir)"
944+
if (Test-Path $currentdir) {
945+
Write-Host "Unlinking $(friendly_path $currentdir)"
946946

947947
# remove read-only attribute on link
948948
attrib $currentdir -R /L
949949

950950
# remove the junction
951-
& "$env:COMSPEC" /c "rmdir `"$currentdir`""
951+
Remove-Item $currentdir -Recurse -Force -ErrorAction Stop
952952
return $currentdir
953953
}
954954
return $versiondir

0 commit comments

Comments
 (0)