Skip to content

Commit 2b676ed

Browse files
committed
alpha release notes for 2023.3 and later fixes #31
1 parent 710e14d commit 2b676ed

File tree

2 files changed

+38
-23
lines changed

2 files changed

+38
-23
lines changed

Diff for: UnityLauncherPro/GetUnityUpdates.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ public static class GetUnityUpdates
2020
public static async Task<List<UnityVersion>> FetchAll()
2121
{
2222
var cachedVersions = LoadCachedVersions();
23-
Console.WriteLine("cachedVersions: "+ cachedVersions);
23+
//Console.WriteLine("cachedVersions: "+ cachedVersions);
2424
var latestCachedVersion = cachedVersions.FirstOrDefault();
2525

26-
Console.WriteLine("FetchAll "+ latestCachedVersion);
26+
//Console.WriteLine("FetchAll "+ latestCachedVersion);
2727
var newVersions = await FetchNewVersions(latestCachedVersion);
28-
Console.WriteLine("newVersions " + newVersions);
28+
//Console.WriteLine("newVersions " + newVersions);
2929

3030
var allVersions = newVersions.Concat(cachedVersions).ToList();
3131

@@ -34,7 +34,7 @@ public static async Task<List<UnityVersion>> FetchAll()
3434
SaveCachedVersions(allVersions);
3535
}
3636

37-
Console.WriteLine("all "+ allVersions);
37+
//Console.WriteLine("all "+ allVersions);
3838

3939
return allVersions;
4040
}

Diff for: UnityLauncherPro/Tools.cs

+34-19
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ public static string GetUnityReleaseURL(string version)
531531

532532
var cleanVersion = CleanVersionNumber(version);
533533
string url = $"https://unity.com/releases/editor/whats-new/{cleanVersion}#notes";
534+
534535
//if (VersionIsArchived(version) == true)
535536
//{
536537
// // remove f#, TODO should remove c# from china version ?
@@ -608,15 +609,17 @@ public static bool OpenReleaseNotes(string version)
608609
{
609610
bool result = false;
610611
if (string.IsNullOrEmpty(version)) return false;
612+
611613
string url = null;
612614
if (Properties.Settings.Default.useAlphaReleaseNotes && HasAlphaReleaseNotes(version))
613615
{
614616
url = GetAlphaReleaseNotesURL(version);
615617
}
616618
else
617619
{
618-
url = Tools.GetUnityReleaseURL(version);
620+
url = GetUnityReleaseURL(version);
619621
}
622+
620623
if (string.IsNullOrEmpty(url)) return false;
621624

622625
OpenURL(url);
@@ -847,8 +850,20 @@ public static string DownloadHTML(string url)
847850
public static string CleanVersionNumber(string version)
848851
{
849852
if (string.IsNullOrEmpty(version)) return null;
850-
// note old patch versions still contains p## in the end
851-
return Regex.Replace(version, @"[f|a|b][0-9]{1,2}", "", RegexOptions.IgnoreCase);
853+
854+
var split = version.Split('.');
855+
float parsedVersion = float.Parse($"{split[0]}.{split[1]}");
856+
// 2023.3 and newer Alpha releases, no replace
857+
if (IsAlpha(version) && parsedVersion >= 2023.3)
858+
{
859+
// do nothing
860+
}
861+
else
862+
{
863+
// note old patch versions still contains p## in the end
864+
version = Regex.Replace(version, @"[f|a|b][0-9]{1,2}", "", RegexOptions.IgnoreCase);
865+
}
866+
return version;
852867
}
853868

854869
private static string FetchUnityVersionNumberFromHTML(string url)
@@ -2216,7 +2231,7 @@ internal static void OpenCustomAssetPath()
22162231
}
22172232
}
22182233
}
2219-
2234+
22202235
private static async Task<bool> DownloadFileAsync(string fileUrl, string destinationPath)
22212236
{
22222237
var cancellationTokenSource = new CancellationTokenSource();
@@ -2229,25 +2244,25 @@ private static async Task<bool> DownloadFileAsync(string fileUrl, string destina
22292244
using (var client = new HttpClient())
22302245
using (var response = await client.GetAsync(fileUrl, HttpCompletionOption.ResponseHeadersRead, cancellationTokenSource.Token))
22312246
{
2232-
response.EnsureSuccessStatusCode();
2247+
response.EnsureSuccessStatusCode();
22332248

2234-
var totalBytes = response.Content.Headers.ContentLength ?? 1;
2235-
var buffer = new byte[8192];
2236-
var totalRead = 0;
2249+
var totalBytes = response.Content.Headers.ContentLength ?? 1;
2250+
var buffer = new byte[8192];
2251+
var totalRead = 0;
22372252

2238-
using (var contentStream = await response.Content.ReadAsStreamAsync())
2239-
using (var fileStream = new FileStream(destinationPath, FileMode.Create, FileAccess.Write,
2240-
FileShare.None, buffer.Length, true))
2253+
using (var contentStream = await response.Content.ReadAsStreamAsync())
2254+
using (var fileStream = new FileStream(destinationPath, FileMode.Create, FileAccess.Write,
2255+
FileShare.None, buffer.Length, true))
2256+
{
2257+
int bytesRead;
2258+
while ((bytesRead = await contentStream.ReadAsync(buffer, 0, buffer.Length, cancellationTokenSource.Token)) > 0)
22412259
{
2242-
int bytesRead;
2243-
while ((bytesRead = await contentStream.ReadAsync(buffer, 0, buffer.Length, cancellationTokenSource.Token)) > 0)
2244-
{
2245-
await fileStream.WriteAsync(buffer, 0, bytesRead, cancellationTokenSource.Token);
2246-
totalRead += bytesRead;
2247-
progressWindow.UpdateProgress(new DownloadProgress(totalRead, totalBytes));
2248-
}
2249-
result = true;
2260+
await fileStream.WriteAsync(buffer, 0, bytesRead, cancellationTokenSource.Token);
2261+
totalRead += bytesRead;
2262+
progressWindow.UpdateProgress(new DownloadProgress(totalRead, totalBytes));
22502263
}
2264+
result = true;
2265+
}
22512266
}
22522267
}
22532268
catch (TaskCanceledException)

0 commit comments

Comments
 (0)