Browse Source

Change Move-Item to Copy-Item

master
lksz 1 year ago
parent
commit
90e1723052
1 changed files with 2 additions and 10 deletions
  1. +2
    -10
      Setup-Profile.ps1

+ 2
- 10
Setup-Profile.ps1 View File

@@ -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 '


Loading…
Cancel
Save