mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Check channel by comparing against LIVE
also change how version comparisons work
This commit is contained in:
parent
0b8b9ea068
commit
607075c9d9
@ -542,11 +542,10 @@ namespace Bloxstrap
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int numCurrentVersion = Utilities.VersionToNumber(App.Version);
|
int versionComparison = Utilities.CompareVersions(App.Version, releaseInfo.TagName);
|
||||||
int numLatestVersion = Utilities.VersionToNumber(releaseInfo.TagName);
|
|
||||||
|
|
||||||
// check if we aren't using a deployed build, so we can update to one if a new version comes out
|
// check if we aren't using a deployed build, so we can update to one if a new version comes out
|
||||||
if (numCurrentVersion == numLatestVersion && App.BuildMetadata.CommitRef.StartsWith("tag") || numCurrentVersion > numLatestVersion)
|
if (versionComparison == 0 && App.BuildMetadata.CommitRef.StartsWith("tag") || versionComparison == -1)
|
||||||
{
|
{
|
||||||
App.Logger.WriteLine($"[Bootstrapper::CheckForUpdates] No updates found");
|
App.Logger.WriteLine($"[Bootstrapper::CheckForUpdates] No updates found");
|
||||||
return;
|
return;
|
||||||
|
@ -12,5 +12,7 @@
|
|||||||
public string BootstrapperVersion { get; set; } = null!;
|
public string BootstrapperVersion { get; set; } = null!;
|
||||||
|
|
||||||
public DateTime? Timestamp { get; set; }
|
public DateTime? Timestamp { get; set; }
|
||||||
|
|
||||||
|
public bool IsBehindDefaultChannel { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#region Properties
|
#region Properties
|
||||||
public const string DefaultChannel = "LIVE";
|
public const string DefaultChannel = "LIVE";
|
||||||
|
|
||||||
|
private static Dictionary<string, ClientVersion> ClientVersionCache = new();
|
||||||
|
|
||||||
// a list of roblox delpoyment locations that we check for, in case one of them don't work
|
// a list of roblox delpoyment locations that we check for, in case one of them don't work
|
||||||
private static List<string> BaseUrls = new()
|
private static List<string> BaseUrls = new()
|
||||||
{
|
{
|
||||||
@ -77,10 +79,19 @@
|
|||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<ClientVersion> GetInfo(string channel, bool timestamp = false)
|
public static async Task<ClientVersion> GetInfo(string channel, bool extraInformation = false)
|
||||||
{
|
{
|
||||||
App.Logger.WriteLine($"[RobloxDeployment::GetInfo] Getting deploy info for channel {channel} (timestamp={timestamp})");
|
App.Logger.WriteLine($"[RobloxDeployment::GetInfo] Getting deploy info for channel {channel} (extraInformation={extraInformation})");
|
||||||
|
|
||||||
|
ClientVersion clientVersion;
|
||||||
|
|
||||||
|
if (ClientVersionCache.ContainsKey(channel))
|
||||||
|
{
|
||||||
|
App.Logger.WriteLine($"[RobloxDeployment::GetInfo] Deploy information is cached");
|
||||||
|
clientVersion = ClientVersionCache[channel];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
HttpResponseMessage deployInfoResponse = await App.HttpClient.GetAsync($"https://clientsettingscdn.roblox.com/v2/client-version/WindowsPlayer/channel/{channel}");
|
HttpResponseMessage deployInfoResponse = await App.HttpClient.GetAsync($"https://clientsettingscdn.roblox.com/v2/client-version/WindowsPlayer/channel/{channel}");
|
||||||
|
|
||||||
string rawResponse = await deployInfoResponse.Content.ReadAsStringAsync();
|
string rawResponse = await deployInfoResponse.Content.ReadAsStringAsync();
|
||||||
@ -101,12 +112,14 @@
|
|||||||
throw new Exception($"Could not get latest deploy for channel {channel}! (HTTP {deployInfoResponse.StatusCode})");
|
throw new Exception($"Could not get latest deploy for channel {channel}! (HTTP {deployInfoResponse.StatusCode})");
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientVersion clientVersion = JsonSerializer.Deserialize<ClientVersion>(rawResponse)!;
|
clientVersion = JsonSerializer.Deserialize<ClientVersion>(rawResponse)!;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// for preferences
|
// for preferences
|
||||||
if (timestamp)
|
if (extraInformation && clientVersion.Timestamp is null)
|
||||||
{
|
{
|
||||||
App.Logger.WriteLine("[RobloxDeployment::GetInfo] Getting timestamp...");
|
App.Logger.WriteLine("[RobloxDeployment::GetInfo] Getting extra information...");
|
||||||
|
|
||||||
string manifestUrl = GetLocation($"/{clientVersion.VersionGuid}-rbxPkgManifest.txt", channel);
|
string manifestUrl = GetLocation($"/{clientVersion.VersionGuid}-rbxPkgManifest.txt", channel);
|
||||||
|
|
||||||
@ -119,7 +132,18 @@
|
|||||||
App.Logger.WriteLine($"[RobloxDeployment::GetInfo] {manifestUrl} - Last-Modified: {lastModified}");
|
App.Logger.WriteLine($"[RobloxDeployment::GetInfo] {manifestUrl} - Last-Modified: {lastModified}");
|
||||||
clientVersion.Timestamp = DateTime.Parse(lastModified).ToLocalTime();
|
clientVersion.Timestamp = DateTime.Parse(lastModified).ToLocalTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if channel is behind LIVE
|
||||||
|
if (channel != DefaultChannel)
|
||||||
|
{
|
||||||
|
var defaultClientVersion = await GetInfo(DefaultChannel);
|
||||||
|
|
||||||
|
if (Utilities.CompareVersions(clientVersion.Version, defaultClientVersion.Version) == -1)
|
||||||
|
clientVersion.IsBehindDefaultChannel = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClientVersionCache[channel] = clientVersion;
|
||||||
|
|
||||||
return clientVersion;
|
return clientVersion;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
|
|
||||||
<StackPanel Grid.Row="3" Grid.ColumnSpan="2" Margin="0,16,0,0" Orientation="Horizontal" Visibility="{Binding ChannelWarningVisibility, Mode=OneWay}">
|
<StackPanel Grid.Row="3" Grid.ColumnSpan="2" Margin="0,16,0,0" Orientation="Horizontal" Visibility="{Binding ChannelWarningVisibility, Mode=OneWay}">
|
||||||
<Image Grid.Column="0" Width="24" Height="24" RenderOptions.BitmapScalingMode="HighQuality" Source="pack://application:,,,/Resources/MessageBox/Warning.png" />
|
<Image Grid.Column="0" Width="24" Height="24" RenderOptions.BitmapScalingMode="HighQuality" Source="pack://application:,,,/Resources/MessageBox/Warning.png" />
|
||||||
<TextBlock Margin="8,0,0,0" VerticalAlignment="Center" Text="This channel may be out of date, as it was last deployed to over a month ago." />
|
<TextBlock Margin="8,0,0,0" VerticalAlignment="Center" Text="This channel is out of date, and is likely no longer being updated. Please use another channel." />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Column="0">
|
<Grid Column="0">
|
||||||
|
@ -27,10 +27,7 @@ namespace Bloxstrap.UI.ViewModels.Menu
|
|||||||
{
|
{
|
||||||
ClientVersion info = await RobloxDeployment.GetInfo(channel, true);
|
ClientVersion info = await RobloxDeployment.GetInfo(channel, true);
|
||||||
|
|
||||||
if (info.Timestamp?.AddMonths(1) < DateTime.Now)
|
ChannelWarningVisibility = info.IsBehindDefaultChannel ? Visibility.Visible : Visibility.Collapsed;
|
||||||
ChannelWarningVisibility = Visibility.Visible;
|
|
||||||
else
|
|
||||||
ChannelWarningVisibility = Visibility.Collapsed;
|
|
||||||
|
|
||||||
ChannelDeployInfo = new DeployInfo
|
ChannelDeployInfo = new DeployInfo
|
||||||
{
|
{
|
||||||
|
@ -15,11 +15,23 @@
|
|||||||
|
|
||||||
public static void ShellExecute(string website) => Process.Start(new ProcessStartInfo { FileName = website, UseShellExecute = true });
|
public static void ShellExecute(string website) => Process.Start(new ProcessStartInfo { FileName = website, UseShellExecute = true });
|
||||||
|
|
||||||
public static int VersionToNumber(string version)
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="versionStr1"></param>
|
||||||
|
/// <param name="versionStr2"></param>
|
||||||
|
/// <returns>
|
||||||
|
/// Result of System.Version.CompareTo <br />
|
||||||
|
/// -1: version1 < version2 <br />
|
||||||
|
/// 0: version1 == version2 <br />
|
||||||
|
/// 1: version1 > version2
|
||||||
|
/// </returns>
|
||||||
|
public static int CompareVersions(string versionStr1, string versionStr2)
|
||||||
{
|
{
|
||||||
// yes this is kinda stupid lol
|
var version1 = new Version(versionStr1.Replace("v", ""));
|
||||||
version = version.Replace("v", "").Replace(".", "");
|
var version2 = new Version(versionStr2.Replace("v", ""));
|
||||||
return Int32.Parse(version);
|
|
||||||
|
return version1.CompareTo(version2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user