Skip to content

Commit c0d7729

Browse files
authored
Merge pull request #74 from SunkenInTime/feature/windows-update-json-utf8
Write release JSON as UTF-8 and log desktop update failures
2 parents 9f12dbc + a31792e commit c0d7729

6 files changed

Lines changed: 41 additions & 6 deletions

File tree

lib/services/windows_desktop_update_controller.dart

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ class WindowsDesktopUpdateController extends ChangeNotifier {
9494
);
9595

9696
if (versionResponse == null) {
97+
_reportInfoSafely(
98+
'No desktop update detected.',
99+
source: 'WindowsDesktopUpdateController.checkVersion',
100+
error: <String, Object?>{
101+
'appArchiveUrl': _appArchiveUrl.toString(),
102+
},
103+
);
97104
return;
98105
}
99106

@@ -119,7 +126,16 @@ class WindowsDesktopUpdateController extends ChangeNotifier {
119126
},
120127
);
121128
notifyListeners();
122-
} catch (_) {
129+
} catch (error, stackTrace) {
130+
_reportInfoSafely(
131+
'Desktop update check failed.',
132+
source: 'WindowsDesktopUpdateController.checkVersion',
133+
error: <String, Object?>{
134+
'appArchiveUrl': _appArchiveUrl.toString(),
135+
'error': error.toString(),
136+
'stackTrace': stackTrace.toString(),
137+
},
138+
);
123139
// Leave the direct installer updater silent if the remote metadata fails.
124140
}
125141
}

release/metadata/4.3.3+87.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"type": "improvement"
5656
},
5757
{
58-
"message": "Online is coming soon\u2122.",
58+
"message": "Online is coming soon.",
5959
"type": "other"
6060
}
6161
]

scripts/build_desktop_release.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ if (-not (Test-Path $metadataPath)) {
6262
)
6363
}
6464

65-
$metadata | ConvertTo-Json -Depth 6 | Set-Content -Path $metadataPath
65+
Write-JsonFileUtf8 -Value $metadata -Path $metadataPath -Depth 6
6666
Write-Host "Created release metadata at $metadataPath"
6767
}
6868
else {
@@ -73,7 +73,7 @@ else {
7373

7474
if ($missingChannels.Count -gt 0) {
7575
$metadata.channels = @($channels + $missingChannels)
76-
$metadata | ConvertTo-Json -Depth 6 | Set-Content -Path $metadataPath
76+
Write-JsonFileUtf8 -Value $metadata -Path $metadataPath -Depth 6
7777
Write-Host ("Updated release metadata channels at {0}: {1}" -f $metadataPath, ($metadata.channels -join ", "))
7878
}
7979
}

scripts/build_store_release.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ $packageInfo = [ordered]@{
4343
sourcePath = $primaryPackage.FullName
4444
}
4545

46-
$packageInfo | ConvertTo-Json -Depth 4 | Set-Content -Path (Join-Path $outputRoot "package-info.json")
46+
Write-JsonFileUtf8 -Value $packageInfo -Path (Join-Path $outputRoot "package-info.json") -Depth 4
4747

4848
Write-Host "Store package staged at $stagedPackagePath" -ForegroundColor Green

scripts/common_release.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,22 @@ function Invoke-RepoCommand {
101101
Pop-Location
102102
}
103103
}
104+
105+
function Write-JsonFileUtf8 {
106+
param(
107+
[Parameter(Mandatory = $true)]
108+
[object]$Value,
109+
[Parameter(Mandatory = $true)]
110+
[string]$Path,
111+
[Parameter()]
112+
[int]$Depth = 8
113+
)
114+
115+
$json = $Value | ConvertTo-Json -Depth $Depth
116+
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
117+
[System.IO.File]::WriteAllText(
118+
[System.IO.Path]::GetFullPath($Path),
119+
$json + [System.Environment]::NewLine,
120+
$utf8NoBom
121+
)
122+
}

scripts/generate_update_manifest.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,5 @@ $manifest = [ordered]@{
9797
items = @($sortedItems)
9898
}
9999

100-
$manifest | ConvertTo-Json -Depth 8 | Set-Content -Path $OutputPath
100+
Write-JsonFileUtf8 -Value $manifest -Path $OutputPath -Depth 8
101101
Write-Host "Generated desktop updater manifest at $OutputPath" -ForegroundColor Green

0 commit comments

Comments
 (0)