@@ -160,6 +160,42 @@ static void ExitFromOverlay(object? sender, RoutedEventArgs args)
160160 }
161161 }
162162
163+ protected virtual async Task < string > DownloadPkgVersion ( DownloadClient downloadClient , RegionResourceVersion ? packageLatestBase )
164+ {
165+ string ? packageExtractBasePath = packageLatestBase ? . decompressed_path ;
166+
167+ // Check Fail-safe: Download pkg_version files if not exist
168+ string pkgVersionPath = Path . Combine ( GamePath , "pkg_version" ) ;
169+ if ( string . IsNullOrEmpty ( packageExtractBasePath ) )
170+ {
171+ return pkgVersionPath ;
172+ }
173+
174+ // Check Fail-safe: Download main pkg_version file
175+ string mainPkgVersionUrl = packageExtractBasePath . CombineURLFromString ( "pkg_version" ) ;
176+ await downloadClient . DownloadAsync ( mainPkgVersionUrl , pkgVersionPath , true ) ;
177+
178+ // Check Fail-safe: Download audio pkg_version files
179+ if ( string . IsNullOrEmpty ( _gameAudioLangListPathStatic ) ||
180+ string . IsNullOrEmpty ( packageExtractBasePath ) )
181+ {
182+ return pkgVersionPath ;
183+ }
184+
185+ if ( ! File . Exists ( _gameAudioLangListPathStatic ) )
186+ {
187+ throw new
188+ FileNotFoundException ( "Game does have audio lang index file but does not exist!"
189+ + $ " Expecting location: { _gameAudioLangListPathStatic } ") ;
190+ }
191+
192+ await DownloadOtherAudioPkgVersion ( _gameAudioLangListPathStatic ,
193+ packageExtractBasePath ,
194+ downloadClient ) ;
195+
196+ return pkgVersionPath ;
197+ }
198+
163199 protected virtual async Task < ( List < LocalFileInfo > , long ) > GetUnusedFileInfoList ( bool includeZipCheck )
164200 {
165201 LoadingMessageHelper . ShowLoadingFrame ( ) ;
@@ -195,32 +231,9 @@ static void ExitFromOverlay(object? sender, RoutedEventArgs args)
195231 DownloadClient downloadClient = DownloadClient . CreateInstance ( httpClient ) ;
196232 RegionResourceVersion ? packageLatestBase = GameVersionManager
197233 . GetGameLatestZip ( gameStateEnum ) . FirstOrDefault ( ) ;
198- string ? packageExtractBasePath = packageLatestBase ? . decompressed_path ;
199234
200- // Check Fail-safe: Download pkg_version files if not exist
201- string pkgVersionPath = Path . Combine ( GamePath , "pkg_version" ) ;
202- if ( ! string . IsNullOrEmpty ( packageExtractBasePath ) )
203- {
204- // Check Fail-safe: Download main pkg_version file
205- string mainPkgVersionUrl = packageExtractBasePath . CombineURLFromString ( "pkg_version" ) ;
206- await downloadClient . DownloadAsync ( mainPkgVersionUrl , pkgVersionPath , true ) ;
207-
208- // Check Fail-safe: Download audio pkg_version files
209- if ( ! string . IsNullOrEmpty ( _gameAudioLangListPathStatic ) &&
210- ! string . IsNullOrEmpty ( packageExtractBasePath ) )
211- {
212- if ( ! File . Exists ( _gameAudioLangListPathStatic ) )
213- {
214- throw new
215- FileNotFoundException ( "Game does have audio lang index file but does not exist!"
216- + $ " Expecting location: { _gameAudioLangListPathStatic } ") ;
217- }
218-
219- await DownloadOtherAudioPkgVersion ( _gameAudioLangListPathStatic ,
220- packageExtractBasePath ,
221- downloadClient ) ;
222- }
223- }
235+ // Download pkg_version file (with additional audio ones)
236+ string pkgVersionPath = await DownloadPkgVersion ( downloadClient , packageLatestBase ) ;
224237
225238 // Check Fail-safe: If the main pkg_version still not exist, throw!
226239 bool isMainPkgVersionExist = File . Exists ( pkgVersionPath ) ;
@@ -341,7 +354,7 @@ protected virtual async ValueTask DownloadOtherAudioPkgVersion(string audioListF
341354 string pkgUrl = baseExtractUrl . CombineURLFromString ( pkgFileName ) ;
342355
343356 // Skip if URL is not found
344- if ( ( await FallbackCDNUtil . GetURLStatusCode ( pkgUrl , default ) ) . StatusCode == HttpStatusCode . NotFound )
357+ if ( ( await FallbackCDNUtil . GetURLStatusCode ( pkgUrl , CancellationToken . None ) ) . StatusCode == HttpStatusCode . NotFound )
345358 {
346359 continue ;
347360 }
0 commit comments