Skip to content

Commit 9dc9ec3

Browse files
authored
Merge pull request #34225 from smoogipoo/fix-release-stream-reset
Write only fixed release streams back to config
2 parents e7beafd + 35a3186 commit 9dc9ec3

File tree

3 files changed

+39
-10
lines changed

3 files changed

+39
-10
lines changed

osu.Game.Tests/NonVisual/TestSceneUpdateManager.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,39 @@ public void TestUserRequestOverridesExistingCheck()
136136
AddUntilStep("no check pending", () => !manager.IsPending);
137137
}
138138

139+
[Test]
140+
public void TestFixedReleaseStreamWrittenToConfig()
141+
{
142+
AddStep("add manager", () =>
143+
{
144+
config = new OsuConfigManager(LocalStorage);
145+
config.SetValue(OsuSetting.ReleaseStream, ReleaseStream.Lazer);
146+
147+
Child = new DependencyProvidingContainer
148+
{
149+
CachedDependencies = [(typeof(OsuConfigManager), config)],
150+
Child = manager = new TestUpdateManager(ReleaseStream.Tachyon)
151+
};
152+
});
153+
154+
AddAssert("release stream set to tachyon", () => config.Get<ReleaseStream>(OsuSetting.ReleaseStream), () => Is.EqualTo(ReleaseStream.Tachyon));
155+
}
156+
139157
private partial class TestUpdateManager : UpdateManager
140158
{
159+
public override ReleaseStream? FixedReleaseStream { get; }
160+
141161
public bool IsPending { get; private set; }
142162
public int Invocations { get; private set; }
143163
public int Completions { get; private set; }
144164

145165
private TaskCompletionSource<bool>? pendingCheck;
146166

167+
public TestUpdateManager(ReleaseStream? fixedReleaseStream = null)
168+
{
169+
FixedReleaseStream = fixedReleaseStream;
170+
}
171+
147172
protected override async Task<bool> PerformUpdateCheck(CancellationToken cancellationToken)
148173
{
149174
Invocations++;

osu.Game/OsuGame.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Diagnostics;
99
using System.IO;
1010
using System.Linq;
11-
using System.Reflection;
1211
using System.Threading;
1312
using System.Threading.Tasks;
1413
using Humanizer;
@@ -1055,13 +1054,6 @@ protected override void LoadComplete()
10551054
{
10561055
base.LoadComplete();
10571056

1058-
if (RuntimeInfo.EntryAssembly.GetCustomAttribute<OfficialBuildAttribute>() == null)
1059-
Logger.Log(NotificationsStrings.NotOfficialBuild.ToString());
1060-
1061-
// Make sure the release stream setting matches the build which was just run.
1062-
if (Enum.TryParse<ReleaseStream>(Version.Split('-').Last(), true, out var releaseStream))
1063-
LocalConfig.SetValue(OsuSetting.ReleaseStream, releaseStream);
1064-
10651057
var languages = Enum.GetValues<Language>();
10661058

10671059
var mappings = languages.Select(language =>

osu.Game/Updater/UpdateManager.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using osu.Framework.Graphics;
1111
using osu.Framework.Graphics.Containers;
1212
using osu.Framework.Graphics.Sprites;
13+
using osu.Framework.Logging;
1314
using osu.Game.Configuration;
1415
using osu.Game.Graphics;
1516
using osu.Game.Localisation;
@@ -56,15 +57,26 @@ protected override void LoadComplete()
5657
string version = game.Version;
5758
string lastVersion = config.Get<string>(OsuSetting.Version);
5859

59-
if (game.IsDeployedBuild && version != lastVersion)
60+
if (game.IsDeployedBuild)
6061
{
6162
// only show a notification if we've previously saved a version to the config file (ie. not the first run).
62-
if (!string.IsNullOrEmpty(lastVersion))
63+
if (!string.IsNullOrEmpty(lastVersion) && version != lastVersion)
6364
Notifications.Post(new UpdateCompleteNotification(version));
6465

66+
// make sure the release stream setting matches the build which was just run.
67+
if (FixedReleaseStream != null)
68+
config.SetValue(OsuSetting.ReleaseStream, FixedReleaseStream.Value);
69+
70+
// notify the user if they're using a build that is not officially sanctioned.
6571
if (RuntimeInfo.EntryAssembly.GetCustomAttribute<OfficialBuildAttribute>() == null)
6672
Notifications.Post(new SimpleNotification { Text = NotificationsStrings.NotOfficialBuild });
6773
}
74+
else
75+
{
76+
// log that this is not an official build, for if users build their own game without an assembly version.
77+
// this is only logged because a notification would be too spammy in local test builds.
78+
Logger.Log(NotificationsStrings.NotOfficialBuild.ToString());
79+
}
6880

6981
// debug / local compilations will reset to a non-release string.
7082
// can be useful to check when an install has transitioned between release and otherwise (see OsuConfigManager's migrations).

0 commit comments

Comments
 (0)