Skip to content

Commit 0b88cb3

Browse files
authored
TTS update fix (#235)
* TTS2 * fixes * addeds Colour
1 parent bde7857 commit 0b88cb3

File tree

4 files changed

+54
-14
lines changed

4 files changed

+54
-14
lines changed

UnitystationLauncher/App.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
<Application.DataTemplates>
77
<local:ViewLocator />
88
</Application.DataTemplates>
9-
109
<Application.Styles>
1110
<FluentTheme />
1211
<StyleInclude Source="/Styles.axaml" />
12+
<Style Selector="TextBlock">
13+
<Setter Property="Foreground" Value="White" />
14+
</Style>
1315
</Application.Styles>
1416
</Application>

UnitystationLauncher/Assets/org.unitystation.StationHub.metainfo.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@
6565
</screenshots>
6666

6767
<releases>
68+
<release version="937" date="2024-12-13">
69+
<description>
70+
<p>Fix:</p>
71+
<ul>
72+
<li>Fixed TTS update not working and resulting in build update not working</li>
73+
</ul>
74+
</description>
75+
</release>
6876
<release version="936" date="2024-12-13">
6977
<description>
7078
<p>Fix:</p>

UnitystationLauncher/Constants/AppInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ public static class AppInfo
44
{
55
// Whenever you change the currentBuild here, please also update the one in
66
// UnitystationLauncher/Assets/org.unitystation.StationHub.metainfo.xml
7-
public const int CurrentBuild = 936;
7+
public const int CurrentBuild = 937;
88
}

UnitystationLauncher/Services/TTSService.cs

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,25 @@ public async Task CheckAndDownloadLatestVersion(Download Download)
115115
{
116116
if (localVersionModel == null || localVersionModel.Version != CurrentVersion.Version)
117117
{
118+
Download.Active = true;
119+
Download.DownloadState = DownloadState.InProgress;
120+
StopTTS();
121+
await Task.Delay(2 * 1000); //to give it some grace period to shutdown
122+
118123
var LocalVersion = System.IO.Path.Combine(installationBasePath, "tts");
119124
if (System.IO.Directory.Exists(LocalVersion))
120125
{
121-
System.IO.Directory.Delete(LocalVersion, true);
126+
foreach (var file in System.IO.Directory.GetFiles(LocalVersion))
127+
{
128+
System.IO.File.Delete(file);
129+
}
130+
131+
foreach (var directory in System.IO.Directory.GetDirectories(LocalVersion))
132+
{
133+
System.IO.Directory.Delete(directory, true);
134+
}
122135
}
123136

124-
125137
var zip = _environmentService.GetCurrentEnvironment() switch
126138
{
127139
CurrentEnvironment.WindowsStandalone => "win.zip",
@@ -130,8 +142,7 @@ public async Task CheckAndDownloadLatestVersion(Download Download)
130142
_ => null
131143
};
132144

133-
Download.Active = true;
134-
Download.DownloadState = DownloadState.InProgress;
145+
135146

136147
HttpResponseMessage request = await _httpClient.GetAsync(ApiUrls.TTSFiles + "/" + zip,
137148
HttpCompletionOption.ResponseHeadersRead);
@@ -166,14 +177,12 @@ private void ExtractTo(Stream progressStream, string LocalVersion, Download Down
166177
case CurrentEnvironment.WindowsStandalone:
167178
{
168179
ZipArchive archive = new(progressStream);
169-
Download.DownloadState = DownloadState.Extracting;
170180
archive.ExtractToDirectory(LocalVersion, true);
171181
break;
172182
}
173183
case CurrentEnvironment.LinuxStandalone or CurrentEnvironment.LinuxFlatpak:
174184
{
175185
using var decompressedStream = DecompressXz(progressStream); // Decompress XZ stream to get .tar
176-
177186
ExtractTar(decompressedStream, LocalVersion);
178187
break;
179188
}
@@ -183,6 +192,7 @@ private void ExtractTo(Stream progressStream, string LocalVersion, Download Down
183192

184193
Download.Active = false;
185194
Download.DownloadState = DownloadState.InProgress;
195+
StartTTS();
186196
}
187197

188198
private static Stream DecompressXz(Stream compressedStream)
@@ -250,11 +260,19 @@ public void StartTTS()
250260
var Preference = _preferencesService.GetPreferences();
251261
if ((Preference.TTSEnabled is true) == false) return;
252262

253-
if (process != null && process.HasExited == false)
263+
try
254264
{
255-
return;
265+
if (process != null && process.HasExited == false)
266+
{
267+
return;
268+
}
269+
}
270+
catch (Exception e)
271+
{
272+
Log.Error(e.ToString());
256273
}
257274

275+
258276
string installationBasePath = _preferencesService.GetPreferences().InstallationPath;
259277
var LocalVersion = System.IO.Path.Combine(installationBasePath, "tts");
260278
if (System.IO.Directory.Exists(LocalVersion) == false)
@@ -303,10 +321,14 @@ public void StartTTS()
303321
// Ensure subprocess ends when the main application exits
304322
AppDomain.CurrentDomain.ProcessExit += (sender, e) =>
305323
{
306-
if (process.HasExited == false)
324+
if (process != null)
307325
{
308-
process.Kill();
326+
if (process.HasExited == false)
327+
{
328+
process.Kill();
329+
}
309330
}
331+
310332
};
311333

312334
try
@@ -324,10 +346,18 @@ public void StopTTS()
324346
{
325347
if (process != null)
326348
{
327-
if (process.HasExited == false)
349+
try
350+
{
351+
if (process.HasExited == false)
352+
{
353+
process.Kill();
354+
}
355+
}
356+
catch (Exception e)
328357
{
329-
process.Kill();
358+
Log.Error(e.ToString());
330359
}
360+
331361
}
332362
}
333363
}

0 commit comments

Comments
 (0)