From 90e17230521ad584f24679084ac8f20a67c8ca93 Mon Sep 17 00:00:00 2001 From: lksz Date: Fri, 2 Oct 2020 15:49:24 -0400 Subject: [PATCH] Change Move-Item to Copy-Item --- Setup-Profile.ps1 | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Setup-Profile.ps1 b/Setup-Profile.ps1 index ae273b3..36f388f 100644 --- a/Setup-Profile.ps1 +++ b/Setup-Profile.ps1 @@ -56,15 +56,7 @@ Get-Command Reload-MyScripts -ErrorAction SilentlyContinue | ForEach-Object { . $local:GitOutput = "$(& git clone $GitURL $tmpGitDir.FullName --no-checkout)" Write-Verbose $GitOutput Write-Verbose "Moving git repo from temp location to $MyPSScriptRoot . . ." - try { - Move-Item (Join-Path $tmpGitDir.FullName .git) ./.git -ErrorAction Stop - } catch { - if( $_.Exception.Message -eq "Invalid cross-device link" ) { - Copy-Item -Recurse (Join-Path $tmpGitDir.FullName .git) ./.git - } else { - throw $_ - } - } + Copy-Item -Recurse (Join-Path $tmpGitDir.FullName .git) ./.git Remove-Item $tmpGitDir.FullName Write-Verbose "Checking out repo..." $GitOutput = "$(& git checkout --force)" @@ -177,7 +169,7 @@ Get-Command Reload-MyScripts -ErrorAction SilentlyContinue | ForEach-Object { . Invoke-ExpressionEx -sudo:$shouldSudo chmod 'a+r' $tmpOutput.FullName } try { - $local:errMsg = $(Invoke-ExpressionEx -sudo:$shouldSudo "Move-Item $($tmpOutput.FullName) $p -Force:`$$Force -ErrorAction Stop | Out-Null" 2>&1) + $local:errMsg = $(Invoke-ExpressionEx -sudo:$shouldSudo "Copy-Item $($tmpOutput.FullName) $p -Force:`$$Force -ErrorAction Stop | Out-Null; Remove-Item $($tmpOutput.FullName) -Force:`$$Force -ErrorAction Stop" 2>&1) if ( $errMsg ) { Write-Error "$errMsg" $status = $status -replace 'Need ', 'Failed '