File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -232,7 +232,7 @@ function Install-ModuleFast {
232232 | Out-File - FilePath $CILockFilePath - Encoding UTF8
233233 }
234234 }
235- clean {
235+ CLEAN {
236236 $cancelSource.Dispose ()
237237 }
238238}
@@ -300,9 +300,10 @@ function Get-ModuleFastPlan {
300300 $ErrorActionPreference = ' Stop'
301301 [HashSet [ModuleFastSpec ]]$modulesToResolve = @ ()
302302
303- # We use this token to cancel the HTTP requests if the user hits ctrl-C without having to dispose of the HttpClient
304- $cancelTokenSource = [CancellationTokenSource ]::new()
305- $CancellationToken ?? = $cancelTokenSource.Token
303+ # We use this token to cancel the HTTP requests if the user hits ctrl-C without having to dispose of the HttpClient.
304+ # We get a child so that a cancellation here does not affect any upstream commands
305+ $cancelTokenSource = $CancellationToken ? [CancellationTokenSource ]::CreateLinkedTokenSource($CancellationToken ) : [CancellationTokenSource ]::new()
306+ $CancellationToken = $cancelTokenSource.Token
306307
307308 # We pass this splat to all our HTTP requests to cut down on boilerplate
308309 $httpContext = @ {
@@ -621,6 +622,12 @@ function Install-ModuleFastHelper {
621622 [HttpClient ]$HttpClient ,
622623 [switch ]$Update
623624 )
625+ BEGIN {
626+ # We use this token to cancel the HTTP requests if the user hits ctrl-C without having to dispose of the HttpClient.
627+ # We get a child so that a cancellation here does not affect any upstream commands
628+ $cancelTokenSource = $CancellationToken ? [CancellationTokenSource ]::CreateLinkedTokenSource($CancellationToken ) : [CancellationTokenSource ]::new()
629+ $CancellationToken = $cancelTokenSource.Token
630+ }
624631 END {
625632 $ErrorActionPreference = ' Stop'
626633
You can’t perform that action at this time.
0 commit comments