diff --git a/CHANGELOG.md b/CHANGELOG.md index 57d0c51b4b..279cbb55d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - **autoupdate:** Allow checksum file that contains whitespaces ([#4619](https://github.com/ScoopInstaller/Scoop/issues/4619)) - **config:** Allow scoop config use Unicode characters ([#4631](https://github.com/ScoopInstaller/Scoop/issues/4631)) +- **current:** Remove 'current' while it's not a junction ([#4687](https://github.com/ScoopInstaller/Scoop/issues/4687)) - **depends:** Prevent error on no URL ([#4595](https://github.com/ScoopInstaller/Scoop/issues/4595)) - **depends:** Check if extractor is available ([#4042](https://github.com/ScoopInstaller/Scoop/issues/4042)) - **decompress:** Fix nested Zstd archive extraction ([#4608](https://github.com/ScoopInstaller/Scoop/issues/4608)) diff --git a/lib/install.ps1 b/lib/install.ps1 index 4d05ca6c18..7d73903d95 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -911,20 +911,20 @@ function current_dir($versiondir) { # Returns the 'current' junction directory if in use, otherwise # the version directory. function link_current($versiondir) { - if(get_config NO_JUNCTIONS) { return $versiondir } + if (get_config NO_JUNCTIONS) { return $versiondir } $currentdir = current_dir $versiondir - write-host "Linking $(friendly_path $currentdir) => $(friendly_path $versiondir)" + Write-Host "Linking $(friendly_path $currentdir) => $(friendly_path $versiondir)" - if($currentdir -eq $versiondir) { + if ($currentdir -eq $versiondir) { abort "Error: Version 'current' is not allowed!" } - if(test-path $currentdir) { + if (Test-Path $currentdir) { # remove the junction attrib -R /L $currentdir - & "$env:COMSPEC" /c rmdir $currentdir + Remove-Item $currentdir -Recurse -Force -ErrorAction Stop } & "$env:COMSPEC" /c mklink /j $currentdir $versiondir | out-null @@ -938,17 +938,17 @@ function link_current($versiondir) { # Returns the 'current' junction directory (if it exists), # otherwise the normal version directory. function unlink_current($versiondir) { - if(get_config NO_JUNCTIONS) { return $versiondir } + if (get_config NO_JUNCTIONS) { return $versiondir } $currentdir = current_dir $versiondir - if(test-path $currentdir) { - write-host "Unlinking $(friendly_path $currentdir)" + if (Test-Path $currentdir) { + Write-Host "Unlinking $(friendly_path $currentdir)" # remove read-only attribute on link attrib $currentdir -R /L # remove the junction - & "$env:COMSPEC" /c "rmdir `"$currentdir`"" + Remove-Item $currentdir -Recurse -Force -ErrorAction Stop return $currentdir } return $versiondir