@@ -68,10 +68,12 @@ function Invoke-ExecContainerManagement {
6868 }
6969
7070 $version = $manifest.annotations .' org.opencontainers.image.version'
71- if (-not $version -and $manifest.config.digest ) {
71+ $created = $manifest.annotations .' org.opencontainers.image.created'
72+ if ((-not $version -or -not $created ) -and $manifest.config.digest ) {
7273 try {
7374 $config = Invoke-RestMethod - Uri " https://ghcr.io/v2/$imagePath /blobs/$ ( $manifest.config.digest ) " - Method GET - Headers $authHeader - ErrorAction Stop
74- $version = $config.config.Labels .' org.opencontainers.image.version'
75+ if (-not $version ) { $version = $config.config.Labels .' org.opencontainers.image.version' }
76+ if (-not $created ) { $created = $config.config.Labels .' org.opencontainers.image.created' }
7577 } catch {
7678 Write-Information " Could not read image config labels for $ ( $imagePath ) :$Tag — $ ( $_.Exception.Message ) "
7779 }
@@ -80,6 +82,7 @@ function Invoke-ExecContainerManagement {
8082 return [pscustomobject ]@ {
8183 Digest = [string ]$digest
8284 Version = [string ]$version
85+ Created = [string ]$created
8386 }
8487 }
8588
@@ -112,8 +115,10 @@ function Invoke-ExecContainerManagement {
112115 }
113116 }
114117
115- # Read update settings and last check result
116- $Settings = Get-CIPPAzDataTableEntity @SettingsTable - Filter " PartitionKey eq 'Settings' and RowKey eq 'UpdateConfig'" | Select-Object - First 1
118+ # Read update settings and last check result, reconciled against the running
119+ # build — a restart may have applied the previously detected update, which
120+ # would otherwise keep showing "update available" until the next check.
121+ $Settings = Sync-CippContainerUpdateState
117122 $UpdateInfo = @ {
118123 AutoUpdate = $false
119124 CheckInterval = ' 0'
@@ -123,6 +128,7 @@ function Invoke-ExecContainerManagement {
123128 RunningVersion = $null
124129 RemoteVersion = $null
125130 RemoteDigest = $null
131+ RemoteBuildDate = $null
126132 }
127133 if ($Settings ) {
128134 $UpdateInfo.AutoUpdate = $Settings.AutoUpdate -eq ' true'
@@ -133,13 +139,15 @@ function Invoke-ExecContainerManagement {
133139 $UpdateInfo.RunningVersion = $Settings.RunningVersion ?? $null
134140 $UpdateInfo.RemoteVersion = $Settings.RemoteVersion ?? $null
135141 $UpdateInfo.RemoteDigest = $Settings.RemoteDigest ?? $null
142+ $UpdateInfo.RemoteBuildDate = $Settings.RemoteBuildDate ?? $null
136143 }
137144
138145 $Body = @ {
139146 Results = @ {
140147 CurrentVersion = $CurrentVersion
141148 CommitSha = $CommitSha
142149 ImageTag = $ImageTag
150+ BuildDate = $env: BUILD_DATE ?? ' unknown'
143151 CurrentChannel = $CurrentChannel
144152 ConfiguredChannel = $ConfiguredChannel
145153 CurrentImage = $CurrentImage
@@ -199,6 +207,7 @@ function Invoke-ExecContainerManagement {
199207 $RemoteInfo = Get-GHCRImageInfo - ImageRef $CurrentImage - Tag $CheckTag
200208 $RemoteVersion = $RemoteInfo.Version
201209 $RemoteDigest = $RemoteInfo.Digest
210+ $RemoteBuildDate = $RemoteInfo.Created
202211
203212 $RunningVersion = $env: APP_VERSION
204213 $UpdateAvailable = $false
@@ -214,6 +223,8 @@ function Invoke-ExecContainerManagement {
214223 RunningVersion = [string ]($RunningVersion ?? ' ' )
215224 RemoteVersion = [string ]($RemoteVersion ?? ' ' )
216225 RemoteDigest = [string ]($RemoteDigest ?? ' ' )
226+ RemoteBuildDate = [string ]($RemoteBuildDate ?? ' ' )
227+ CheckedTag = [string ]($CheckTag ?? ' ' )
217228 }
218229 $Existing = Get-CIPPAzDataTableEntity @SettingsTable - Filter " PartitionKey eq 'Settings' and RowKey eq 'UpdateConfig'" | Select-Object - First 1
219230 if ($Existing ) {
@@ -241,6 +252,7 @@ function Invoke-ExecContainerManagement {
241252 RunningVersion = $RunningVersion
242253 RemoteVersion = $RemoteVersion
243254 RemoteDigest = $RemoteDigest
255+ RemoteBuildDate = $RemoteBuildDate
244256 CheckedTag = $CheckTag
245257 }
246258 }
@@ -266,7 +278,8 @@ function Invoke-ExecContainerManagement {
266278 throw " Invalid check time: $CheckTime . Must be 0-23 (UTC hour)."
267279 }
268280
269- # Read existing settings to preserve check results
281+ # Read existing settings to preserve check results — the upsert replaces the
282+ # whole entity, so every check-result field must be carried over here.
270283 $Existing = Get-CIPPAzDataTableEntity @SettingsTable - Filter " PartitionKey eq 'Settings' and RowKey eq 'UpdateConfig'" | Select-Object - First 1
271284 $Entity = @ {
272285 PartitionKey = ' Settings'
@@ -276,8 +289,11 @@ function Invoke-ExecContainerManagement {
276289 CheckTime = [string ]($CheckTime ?? ' ' )
277290 LastCheck = [string ]($Existing.LastCheck ?? ' ' )
278291 UpdateAvailable = [string ]($Existing.UpdateAvailable ?? ' false' )
279- RunningDigest = [string ]($Existing.RunningDigest ?? ' ' )
292+ RunningVersion = [string ]($Existing.RunningVersion ?? ' ' )
293+ RemoteVersion = [string ]($Existing.RemoteVersion ?? ' ' )
280294 RemoteDigest = [string ]($Existing.RemoteDigest ?? ' ' )
295+ RemoteBuildDate = [string ]($Existing.RemoteBuildDate ?? ' ' )
296+ CheckedTag = [string ]($Existing.CheckedTag ?? ' ' )
281297 }
282298 Add-CIPPAzDataTableEntity @SettingsTable - Entity $Entity - Force | Out-Null
283299
0 commit comments