From fe3021b3f2ec9d264c398ce354322f5087630640 Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Tue, 12 Dec 2017 15:31:21 +0100
Subject: [PATCH] Update service binaries update location to recent changes.

Refers to #13
---
 AutoTx-Updater/Update-Service.ps1 | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/AutoTx-Updater/Update-Service.ps1 b/AutoTx-Updater/Update-Service.ps1
index db8e71c..1874112 100644
--- a/AutoTx-Updater/Update-Service.ps1
+++ b/AutoTx-Updater/Update-Service.ps1
@@ -205,8 +205,14 @@ function Update-Configuration {
 
 function Copy-ServiceFiles {
     try {
+        Write-Verbose "Looking for source package using pattern: $($Pattern)"
+        $PkgDir = Get-ChildItem -Path $UpdateBinariesPath -Directory -Name |
+            Where-Object {$_ -match $Pattern} |
+            Sort-Object |
+            Select-Object -Last 1
+        Write-Verbose "Update source package: $($PkgDir)"
         Copy-Item -Recurse -Force -ErrorAction Stop `
-            -Path "$($UpdateBinariesPath)\$($ServiceName)\*" `
+            -Path "$($UpdateBinariesPath)\$($PkgDir)\$($ServiceName)\*" `
             -Destination "$InstallationPath"
     }
     catch {
@@ -307,7 +313,7 @@ Check-ServiceState $ServiceName
 
 $UpdateConfigPath = "$($UpdateSourcePath)\Configs\$($env:COMPUTERNAME)"
 $UpdateMarkerPath = "$($UpdateSourcePath)\Service\UpdateMarkers"
-$UpdateBinariesPath = "$($UpdateSourcePath)\Service\Binaries\Latest"
+$UpdateBinariesPath = "$($UpdateSourcePath)\Service\Binaries"
 
 Exit-IfDirMissing $InstallationPath "installation"
 Exit-IfDirMissing $UpdateSourcePath "update source"
-- 
GitLab