forked from chocolatey-archive/chocolatey
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moving bad installs when an installer fails chocolatey-archive#10
- Loading branch information
1 parent
177631d
commit 54e44a1
Showing
3 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function Move-BadInstall { | ||
param( | ||
[string] $packageName, | ||
[string] $version = '', | ||
[string] $packageFolder = '' | ||
) | ||
Write-Debug "Running 'Move-BadInstall' for $packageName version: `'$version`', packageFolder:`'$packageFolder`'"; | ||
|
||
#copy the bad stuff to a temp directory | ||
$badPackageFolder = Join-Path $badLibPath "$($installedPackageName).$($installedPackageVersion)" | ||
try { | ||
if ([System.IO.Directory]::Exists($badPackageFolder)) { | ||
[System.IO.Directory]::Delete($badPackageFolder,$true) #| out-null | ||
} | ||
[System.IO.Directory]::CreateDirectory($badPackageFolder) | out-null | ||
|
||
write-debug "Moving bad package `'$packageName v$version`' to `'$badPackageFolder`'." | ||
#Get-Childitem "$badPackageFolder" -recurse | remove-item | ||
Move-Item $packageFolder $badPackageFolder -force #| out-null | ||
} catch { | ||
Write-Error "Could not move bad package $packageName from `'$packageFolder`' to `'$badPackageFolder`': $($_.Exception.Message)" | ||
} | ||
|
||
} |