Skip to content
Snippets Groups Projects
Commit 48c21d13 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Adapt Copy-ServiceFiles to changes in control logic.

Locating the update package is now done in Find-InstallationPackage and
stored in $UpdPackage, so we can safely remove the redundant code. In
addition, this change makes the function return $True or $False,
depending if the copy action succeeded.

Refers to #28
parent e69013b4
No related branches found
No related tags found
No related merge requests found
......@@ -350,29 +350,23 @@ function Find-InstallationPackage {
function Copy-ServiceFiles {
# Copy the files from an update package to the service installation
# directory, overwriting existing ones.
#
# Returns $True for success, $False otherwise.
Write-Verbose "Copying service binaries from [$($UpdPackage)]..."
try {
Write-Verbose "Looking for source package using pattern: $($Pattern)"
$PkgDir = Get-ChildItem -Path $UpdPathBinaries -Directory -Name |
Where-Object {$_ -match $Pattern} |
Sort-Object |
Select-Object -Last 1
if ([string]::IsNullOrEmpty($PkgDir)) {
Write-Host "ERROR: couldn't find package matching '$($Pattern)'!"
Exit
}
Write-Verbose "Found update source package: [$($PkgDir)]"
Stop-MyService "Trying to update service using package [$($PkgDir)]."
Copy-Item -Recurse -Force -ErrorAction Stop `
-Path "$($UpdPathBinaries)\$($PkgDir)\$($ServiceName)\*" `
Copy-Item -Recurse -Force `
-Path "$($UpdPackage)\$($ServiceName)\*" `
-Destination "$InstallationPath"
}
catch {
Exit
Log-Error "Updating service binaries FAILED:`n> $($_.Exception.Message)"
Return $False
}
Log-Info "Updated service binaries with [$($PkgDir)]."
Log-Info "Updated service binaries with [$($UpdPackage)]."
Return $True
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment