3131using System . Security . Cryptography ;
3232using System . Threading ;
3333using System . Threading . Tasks ;
34+ #pragma warning disable IDE0130
3435
3536#nullable enable
3637namespace CollapseLauncher . InstallManager . Base
@@ -113,7 +114,7 @@ await SophonPatch.CreateSophonChunkManifestInfoPair(httpClient,
113114
114115 // Create a sophon download speed limiter instance
115116 SophonDownloadSpeedLimiter downloadSpeedLimiter =
116- SophonDownloadSpeedLimiter . CreateInstance ( LauncherConfig . DownloadSpeedLimitCached ) ;
117+ SophonDownloadSpeedLimiter . CreateInstance ( nint . Zero ) ;
117118
118119 // Get the patch assets to download
119120 ( List < SophonPatchAsset > AssetList , List < SophonChunkManifestInfoPair > InfoPairs , bool IsAllowRemoveOldFile ) patchAssets =
@@ -142,8 +143,8 @@ await StartAlterSophonPatch(httpClient,
142143 }
143144
144145 public virtual Task FilterAssetList < T > (
145- List < T > itemList ,
146- Func < T , string ? > itemPathSelector ,
146+ List < T > itemList ,
147+ Func < T , string ? > itemPathSelector ,
147148 CancellationToken token )
148149 {
149150 // NOP
@@ -168,16 +169,16 @@ protected virtual async Task ConfirmAdditionalPatchDataPackageFiles(SophonChunkM
168169 long sizeCurrentToDownload = patchManifest . OtherSophonPatchData . ManifestIdentityList
169170 . Where ( x => matchingFieldsList . Contains ( x . MatchingField , StringComparer . OrdinalIgnoreCase ) )
170171 . Sum ( x =>
171- {
172- SophonManifestChunkInfo ? firstTag = x . DiffTaggedInfo . FirstOrDefault ( y => y . Key == currentVersion ) . Value ;
173- return firstTag ? . CompressedSize ?? 0 ;
174- } ) ;
172+ {
173+ SophonManifestChunkInfo ? firstTag = x . DiffTaggedInfo . FirstOrDefault ( y => y . Key == currentVersion ) . Value ;
174+ return firstTag ? . CompressedSize ?? 0 ;
175+ } ) ;
175176 long sizeAdditionalToDownload = otherManifestIdentity
176177 . Sum ( x =>
177- {
178- SophonManifestChunkInfo ? firstTag = x . DiffTaggedInfo . FirstOrDefault ( y => y . Key == currentVersion ) . Value ;
179- return firstTag ? . CompressedSize ?? 0 ;
180- } ) ;
178+ {
179+ SophonManifestChunkInfo ? firstTag = x . DiffTaggedInfo . FirstOrDefault ( y => y . Key == currentVersion ) . Value ;
180+ return firstTag ? . CompressedSize ?? 0 ;
181+ } ) ;
181182
182183 if ( AskAdditionalSophonPkg )
183184 {
@@ -199,11 +200,11 @@ string GetFileDetails()
199200 {
200201 string filePath = Path . GetTempFileName ( ) ;
201202 filePath = Path . Combine ( Path . GetDirectoryName ( filePath ) ?? "" , Path . GetFileNameWithoutExtension ( filePath ) + ".log" ) ;
202-
203+
203204 long sizeUncompressed = 0 ;
204- long sizeCompressed = 0 ;
205- long fileCount = 0 ;
206- long chunkCount = 0 ;
205+ long sizeCompressed = 0 ;
206+ long fileCount = 0 ;
207+ long chunkCount = 0 ;
207208
208209 // ReSharper disable once ConvertToUsingDeclaration
209210 using ( FileStream fileStream = new ( filePath , FileMode . Create , FileAccess . Write ) )
@@ -224,10 +225,10 @@ string GetFileDetails()
224225 writer . WriteLine ( $ " File Count: { fieldInfo . FileCount } ") ;
225226 writer . WriteLine ( ) ;
226227
227- sizeCompressed += fieldInfo . CompressedSize ;
228+ sizeCompressed += fieldInfo . CompressedSize ;
228229 sizeUncompressed += fieldInfo . UncompressedSize ;
229- fileCount += fieldInfo . FileCount ;
230- chunkCount += fieldInfo . ChunkCount ;
230+ fileCount += fieldInfo . FileCount ;
231+ chunkCount += fieldInfo . ChunkCount ;
231232 }
232233
233234 writer . WriteLine ( $ "Total Patch Size to Download (Compressed): { ConverterTool . SummarizeSizeSimple ( sizeCompressed ) } ({ sizeCompressed } bytes)") ;
@@ -279,31 +280,31 @@ private async Task<bool> SpawnAdditionalPackageDownloadDialog(long baseDownloadS
279280 cornerRadius : new CornerRadius ( 14 ) ) ;
280281 showFileDetails . WithMargin ( new Thickness ( 0 , 16d , 0 , 0 ) ) ;
281282 showFileDetails . Click += async ( sender , _ ) =>
282- {
283- if ( sender is not ButtonBase button )
284- {
285- return ;
286- }
287-
288- button . IsEnabled = false ;
289-
290- string filePath = getFileDetailPath . Invoke ( ) ;
291- if ( ! string . IsNullOrEmpty ( filePath ) )
292- {
293- Process process = new Process
294- {
295- StartInfo = new ProcessStartInfo
296- {
297- FileName = filePath ,
298- UseShellExecute = true
299- }
300- } ;
301- process . Start ( ) ;
302- }
303-
304- await Task . Delay ( TimeSpan . FromSeconds ( 2 ) ) ;
305- button . IsEnabled = true ;
306- } ;
283+ {
284+ if ( sender is not ButtonBase button )
285+ {
286+ return ;
287+ }
288+
289+ button . IsEnabled = false ;
290+
291+ string filePath = getFileDetailPath . Invoke ( ) ;
292+ if ( ! string . IsNullOrEmpty ( filePath ) )
293+ {
294+ Process process = new Process
295+ {
296+ StartInfo = new ProcessStartInfo
297+ {
298+ FileName = filePath ,
299+ UseShellExecute = true
300+ }
301+ } ;
302+ process . Start ( ) ;
303+ }
304+
305+ await Task . Delay ( TimeSpan . FromSeconds ( 2 ) ) ;
306+ button . IsEnabled = true ;
307+ } ;
307308
308309 grid . AddElementToGridRow ( showFileDetails , 1 ) ;
309310 }
@@ -333,8 +334,8 @@ private async Task<bool> SpawnAdditionalPackageDownloadDialog(long baseDownloadS
333334 SophonDownloadSpeedLimiter downloadLimiter ,
334335 CancellationToken token )
335336 {
336- SophonChunkManifestInfoPair ? rootPatchManifest = null ;
337- SophonChunkManifestInfoPair ? rootMainManifest = null ;
337+ SophonChunkManifestInfoPair ? rootPatchManifest = null ;
338+ SophonChunkManifestInfoPair ? rootMainManifest = null ;
338339 List < ( SophonChunkManifestInfoPair Patch , SophonChunkManifestInfoPair Main , bool IsCommon ) > patchManifestList = [ ] ;
339340 bool isAlowRemoveOldFile = true ;
340341
@@ -452,14 +453,14 @@ protected virtual async Task<List<string>> GetAlterSophonPatchVOMatchingFields(C
452453 return voAudioMatchingFields ;
453454 }
454455
455- protected virtual async Task StartAlterSophonPatch ( HttpClient httpClient ,
456- bool isPreloadMode ,
457- List < SophonPatchAsset > patchAssets ,
456+ protected virtual async Task StartAlterSophonPatch ( HttpClient httpClient ,
457+ bool isPreloadMode ,
458+ List < SophonPatchAsset > patchAssets ,
458459 List < SophonChunkManifestInfoPair > patchManifestInfoPairs ,
459- bool isAllowRemoveOldFile ,
460- SophonDownloadSpeedLimiter downloadLimiter ,
461- int threadNum ,
462- CancellationToken token )
460+ bool isAllowRemoveOldFile ,
461+ SophonDownloadSpeedLimiter downloadLimiter ,
462+ int threadNum ,
463+ CancellationToken token )
463464 {
464465 Dictionary < string , int > downloadedPatchHashSet = new ( ) ;
465466 Lock dictionaryLock = new ( ) ;
@@ -476,9 +477,9 @@ protected virtual async Task StartAlterSophonPatch(HttpClient
476477 ParallelOptions parallelOptions = new ( )
477478 {
478479 MaxDegreeOfParallelism = threadNum ,
479- CancellationToken = token
480+ CancellationToken = token
480481 } ;
481-
482+
482483 if ( LauncherConfig . GetAppConfigValue ( "SophonPreloadApplyPerfMode" ) )
483484 {
484485 parallelOptions . MaxDegreeOfParallelism = Environment . ProcessorCount ;
@@ -505,7 +506,7 @@ await EnsureDiskSpaceSufficiencyAsync(downloadSizePatchOnlyRemote,
505506 }
506507
507508 string patchFilePath = Path . Combine ( patchOutputDir , asset . PatchHash ) ;
508- FileInfo patchFileInfo = new FileInfo ( patchFilePath ) ;
509+ FileInfo patchFileInfo = new ( patchFilePath ) ;
509510
510511 if ( ! patchFileInfo . Exists )
511512 {
@@ -520,12 +521,12 @@ await EnsureDiskSpaceSufficiencyAsync(downloadSizePatchOnlyRemote,
520521 token ) ;
521522
522523 // Assign local download progress
523- ProgressAllCountCurrent = 0 ;
524- ProgressAllCountTotal = pipelineDownloadEnumerable . Count ;
525- ProgressPerFileSizeCurrent = 0 ;
526- ProgressPerFileSizeTotal = downloadSizePatchOnlyRemote ;
527- ProgressAllSizeCurrent = 0 ;
528- ProgressAllSizeTotal = downloadSizePatchOnlyRemote ;
524+ ProgressAllCountCurrent = 0 ;
525+ ProgressAllCountTotal = pipelineDownloadEnumerable . Count ;
526+ ProgressPerFileSizeCurrent = 0 ;
527+ ProgressPerFileSizeTotal = downloadSizePatchOnlyRemote ;
528+ ProgressAllSizeCurrent = 0 ;
529+ ProgressAllSizeTotal = downloadSizePatchOnlyRemote ;
529530 Status . IsIncludePerFileIndicator = false ;
530531
531532 // Run parallel pipeline for download
@@ -538,12 +539,12 @@ await EnsureDiskSpaceSufficiencyAsync(downloadSizePatchOnlyRemote,
538539 }
539540
540541 // If it's not a preload mode (patch mode), then execute the patch pipeline as well
541- ProgressAllCountCurrent = 0 ;
542- ProgressAllCountTotal = downloadCountTotalAssetRemote ;
543- ProgressPerFileSizeCurrent = 0 ;
544- ProgressPerFileSizeTotal = downloadSizePatchOnlyRemote ;
545- ProgressAllSizeCurrent = 0 ;
546- ProgressAllSizeTotal = downloadSizeTotalAssetRemote ;
542+ ProgressAllCountCurrent = 0 ;
543+ ProgressAllCountTotal = downloadCountTotalAssetRemote ;
544+ ProgressPerFileSizeCurrent = 0 ;
545+ ProgressPerFileSizeTotal = downloadSizePatchOnlyRemote ;
546+ ProgressAllSizeCurrent = 0 ;
547+ ProgressAllSizeTotal = downloadSizeTotalAssetRemote ;
547548 Status . IsIncludePerFileIndicator = true ;
548549
549550 // Run parallel pipeline for patch
@@ -558,7 +559,7 @@ await EnsureDiskSpaceSufficiencyAsync(downloadSizePatchOnlyRemote,
558559
559560 async ValueTask ImplDownload ( Tuple < SophonPatchAsset , Dictionary < string , int > > ctx , CancellationToken innerToken )
560561 {
561- SophonPatchAsset patchAsset = ctx . Item1 ;
562+ SophonPatchAsset patchAsset = ctx . Item1 ;
562563 Dictionary < string , int > downloadedDict = ctx . Item2 ;
563564
564565 try
@@ -684,4 +685,4 @@ void UpdateCurrentPatchStatus()
684685 }
685686 }
686687 }
687- }
688+ }
0 commit comments