Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit454afeb

Browse files
committed
handle missing releases, comparing batches to all cached versions (since releases api is not in order)
1 parent2b676ed commit454afeb

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

‎UnityLauncherPro/GetUnityUpdates.cs‎

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ public static class GetUnityUpdates
2020
publicstaticasyncTask<List<UnityVersion>>FetchAll()
2121
{
2222
varcachedVersions=LoadCachedVersions();
23-
//Console.WriteLine("cachedVersions: "+ cachedVersions);
24-
varlatestCachedVersion=cachedVersions.FirstOrDefault();
25-
26-
//Console.WriteLine("FetchAll "+ latestCachedVersion);
27-
varnewVersions=awaitFetchNewVersions(latestCachedVersion);
28-
//Console.WriteLine("newVersions " + newVersions);
23+
varnewVersions=awaitFetchNewVersions(cachedVersions);
2924

3025
varallVersions=newVersions.Concat(cachedVersions).ToList();
3126

@@ -34,8 +29,6 @@ public static async Task<List<UnityVersion>> FetchAll()
3429
SaveCachedVersions(allVersions);
3530
}
3631

37-
//Console.WriteLine("all "+ allVersions);
38-
3932
returnallVersions;
4033
}
4134

@@ -62,7 +55,6 @@ public static async Task<string> FetchDownloadUrl(string unityVersion)
6255

6356
privatestaticasyncTask<string>ExtractDownloadUrlAsync(stringjson,stringunityVersion)
6457
{
65-
6658
intresultsIndex=json.IndexOf("\"results\":");
6759
if(resultsIndex==-1)returnnull;
6860

@@ -122,28 +114,39 @@ private static async Task<bool> CheckAssistantUrl(string assistantUrl)
122114
}
123115
}
124116

125-
privatestaticasyncTask<List<UnityVersion>>FetchNewVersions(UnityVersionlatestCachedVersion)
117+
privatestaticasyncTask<List<UnityVersion>>FetchNewVersions(List<UnityVersion>cachedVersions)
126118
{
127119
varnewVersions=newList<UnityVersion>();
120+
varcachedVersionSet=newHashSet<string>(cachedVersions.Select(v=>v.Version));
128121
intoffset=0;
129122
inttotal=int.MaxValue;
123+
boolfoundNewVersionInBatch;
130124

131125
while(offset<total)
132126
{
133127
varbatchUpdates=awaitFetchBatch(offset);
134-
if(batchUpdates==null||batchUpdates.Count==0)
135-
break;
128+
if(batchUpdates==null||batchUpdates.Count==0)break;
129+
130+
foundNewVersionInBatch=false;
136131

137132
foreach(varversioninbatchUpdates)
138133
{
139-
if(version.Version==latestCachedVersion?.Version)
140-
returnnewVersions;
134+
if(!cachedVersionSet.Contains(version.Version))
135+
{
136+
newVersions.Add(version);
137+
foundNewVersionInBatch=true;
138+
}
139+
}
141140

142-
newVersions.Add(version);
141+
if(!foundNewVersionInBatch)
142+
{
143+
// Exit if no new versions are found in the current batch
144+
break;
143145
}
144146

145147
offset+=batchUpdates.Count;
146148

149+
// Apply delay if reaching batch limit
147150
if(offset%(BatchSize*RequestsPerBatch)==0)
148151
{
149152
awaitTask.Delay(DelayBetweenBatches);
@@ -153,6 +156,8 @@ private static async Task<List<UnityVersion>> FetchNewVersions(UnityVersion late
153156
returnnewVersions;
154157
}
155158

159+
160+
156161
privatestaticasyncTask<List<UnityVersion>>FetchBatch(intoffset)
157162
{
158163
stringurl=$"{BaseApiUrl}?limit={BatchSize}&offset={offset}&architecture=X86_64&platform=WINDOWS";
@@ -187,6 +192,7 @@ private static List<UnityVersion> ParseUnityVersions(string json)
187192
ReleaseDate=DateTime.TryParse(GetStringValue(item,"releaseDate"),outvardate)?date:default,
188193
Stream=Enum.TryParse<UnityVersionStream>(GetStringValue(item,"stream"),true,outvarstream)?stream:UnityVersionStream.Tech
189194
};
195+
//Console.WriteLine(version.Version);
190196
versions.Add(version);
191197
}
192198
}

‎UnityLauncherPro/Tools.cs‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,8 @@ public static Process LaunchExe(string path, string param = null)
520520
}
521521
returnnewProcess;
522522
}
523-
Console.WriteLine("Failed to run exe: "+path+" "+param);
524-
returnnull;
523+
// Console.WriteLine("Failed to run exe: " + path + " " + param);
524+
// return null;
525525
}
526526

527527

@@ -868,8 +868,6 @@ public static string CleanVersionNumber(string version)
868868

869869
privatestaticstringFetchUnityVersionNumberFromHTML(stringurl)
870870
{
871-
stringversion=null;
872-
873871
stringsourceHTML=DownloadHTML(url);
874872

875873
if(string.IsNullOrEmpty(sourceHTML))returnnull;
@@ -882,7 +880,7 @@ private static string FetchUnityVersionNumberFromHTML(string url)
882880
{
883881
Console.WriteLine("Extracted number: "+match.Value);
884882
returnmatch.Value;
885-
break;
883+
//break;
886884
}
887885
}
888886
else
@@ -902,7 +900,7 @@ private static string FetchUnityVersionNumberFromHTML(string url)
902900
// version = match.Value.Replace("UnityDownloadAssistant-", "").Replace(".exe", "");
903901
// }
904902
//}
905-
returnversion;
903+
//return version;
906904
}
907905

908906
publicstaticstringFindNearestVersion(stringcurrentVersion,List<string>allAvailable,boolcheckBelow=false)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp