@@ -18,7 +18,7 @@ public static class GetUnityUpdates
1818 private const int DelayBetweenBatches = 1000 ; // 1 second in milliseconds
1919 private const string CacheFileName = "UnityVersionCache.json" ;
2020
21- private static readonly HttpClient httpClient = new HttpClient ( ) ;
21+ private static readonly HttpClient Client = new HttpClient ( ) ;
2222
2323 public static async Task < List < UnityVersion > > FetchAll ( )
2424 {
@@ -37,7 +37,7 @@ public static async Task<List<UnityVersion>> FetchAll()
3737 return allVersions ;
3838 }
3939
40- public static async Task < string > FetchDownloadUrl ( string unityVersion , bool assistantUrl = false )
40+ public static async Task < string > FetchDownloadUrl ( string unityVersion )
4141 {
4242 if ( string . IsNullOrEmpty ( unityVersion ) )
4343 {
@@ -48,7 +48,7 @@ public static async Task<string> FetchDownloadUrl(string unityVersion, bool assi
4848
4949 try
5050 {
51- string responseString = await httpClient . GetStringAsync ( apiUrl ) ;
51+ string responseString = await Client . GetStringAsync ( apiUrl ) ;
5252 JsonDocument doc = JsonDocument . Parse ( responseString ) ;
5353 try
5454 {
@@ -75,21 +75,37 @@ public static async Task<string> FetchDownloadUrl(string unityVersion, bool assi
7575
7676 if ( ! string . IsNullOrEmpty ( downloadUrl ) )
7777 {
78- if ( ! assistantUrl ) return downloadUrl ;
79-
8078 if ( ! string . IsNullOrEmpty ( shortRevision ) )
8179 {
8280 var startIndex = downloadUrl . LastIndexOf ( shortRevision , StringComparison . Ordinal ) + shortRevision . Length + 1 ;
8381 var endIndex = downloadUrl . Length - startIndex ;
84- return downloadUrl . Replace ( downloadUrl . Substring ( startIndex , endIndex ) ,
82+ var assistantUrl = downloadUrl . Replace ( downloadUrl . Substring ( startIndex , endIndex ) ,
8583 $ "UnityDownloadAssistant-{ unityVersion } .exe") ;
84+ using ( var assistantResponse = await Client . GetAsync ( assistantUrl ) )
85+ {
86+ if ( assistantResponse . IsSuccessStatusCode )
87+ {
88+ Console . WriteLine ( "Assistant download URL found." ) ;
89+ return assistantUrl ;
90+ }
91+ else
92+ {
93+ Console . WriteLine ( "Assistant download URL not found, returning original download URL." ) ;
94+ return downloadUrl ;
95+ }
96+ }
8697 }
8798 else
8899 {
89100 Console . WriteLine ( "ShortRevision not found, returning original download URL." ) ;
90101 return downloadUrl ;
91102 }
92103 }
104+ else
105+ {
106+ Console . WriteLine ( "No download URL found." ) ;
107+ return downloadUrl ;
108+ }
93109 }
94110
95111 Console . WriteLine ( $ "No download URL found for version { unityVersion } ") ;
@@ -145,7 +161,7 @@ private static async Task<UnityVersionResponse> FetchBatch(int offset)
145161
146162 try
147163 {
148- var response = await httpClient . GetStringAsync ( url ) ;
164+ var response = await Client . GetStringAsync ( url ) ;
149165 return JsonSerializer . Deserialize < UnityVersionResponse > ( response ) ;
150166 }
151167 catch ( Exception e )
0 commit comments