@@ -771,9 +771,43 @@ private long GetAssetIndexTotalUncompressSize(List<GameInstallPackage> assetInde
771771
772772 private long GetSingleOrSegmentedUncompressedSize ( GameInstallPackage asset )
773773 {
774- using Stream stream = GetSingleOrSegmentedDownloadStream ( asset ) ;
775- using ArchiveFile archiveFile = ArchiveFile . Create ( stream , true ) ;
776- return archiveFile . Entries . Sum ( x => ( long ) x ! . Size ) ;
774+ using Stream stream = GetSingleOrSegmentedDownloadStream ( asset ) ;
775+
776+ #if USENEWZIPDECOMPRESS
777+ Func < Stream , long > summaryDelegate ;
778+ if ( LauncherConfig . IsEnforceToUse7zipOnExtract )
779+ {
780+ summaryDelegate = GetArchiveUncompressedSizeNative7zip ;
781+ }
782+ else if ( ( asset . PathOutput . EndsWith ( ".zip" , StringComparison . OrdinalIgnoreCase ) ||
783+ asset . PathOutput . EndsWith ( ".zip.001" , StringComparison . OrdinalIgnoreCase ) ) &&
784+ ! _isAllowExtractCorruptZip )
785+ {
786+ summaryDelegate = GetArchiveUncompressedSizeManaged ;
787+ }
788+ else
789+ {
790+ summaryDelegate = GetArchiveUncompressedSizeNative7zip ;
791+ }
792+ #else
793+ Func < Stream , long > summaryDelegate = GetArchiveUncompressedSizeNative7zip ;
794+ #endif
795+
796+ return summaryDelegate ( stream ) ;
797+ }
798+
799+ #if USENEWZIPDECOMPRESS
800+ private long GetArchiveUncompressedSizeManaged ( Stream archiveStream )
801+ {
802+ using ZipArchive archive = ZipArchive . Open ( archiveStream ) ;
803+ return archive . Entries . Select ( x => x . Size ) . ToArray ( ) . Sum ( ) ;
804+ }
805+ #endif
806+
807+ private long GetArchiveUncompressedSizeNative7zip ( Stream archiveStream )
808+ {
809+ using ArchiveFile archiveFile = ArchiveFile . Create ( archiveStream , true ) ;
810+ return archiveFile . Entries . Select ( x => ( long ) x . Size ) . ToArray ( ) . Sum ( ) ;
777811 }
778812
779813 private Stream GetSingleOrSegmentedDownloadStream ( GameInstallPackage asset )
@@ -869,20 +903,20 @@ protected virtual async Task StartPackageInstallationInner(List<GameInstallPacka
869903 InstallPackageExtractorDelegate installTaskDelegate ;
870904 if ( LauncherConfig . IsEnforceToUse7zipOnExtract )
871905 {
872- installTaskDelegate = ExtractUsing7zip ;
906+ installTaskDelegate = ExtractUsingNative7zip ;
873907 }
874908 else if ( ( asset ! . PathOutput . EndsWith ( ".zip" , StringComparison . OrdinalIgnoreCase )
875909 || asset ! . PathOutput . EndsWith ( ".zip.001" , StringComparison . OrdinalIgnoreCase ) )
876910 && ! _isAllowExtractCorruptZip )
877911 {
878- installTaskDelegate = ExtractUsingNativeZip ;
912+ installTaskDelegate = ExtractUsingManagedZip ;
879913 }
880914 else
881915 {
882- installTaskDelegate = ExtractUsing7zip ;
916+ installTaskDelegate = ExtractUsingNative7zip ;
883917 }
884918 #else
885- InstallPackageExtractorDelegate installTaskDelegate = ExtractUsing7zip ;
919+ InstallPackageExtractorDelegate installTaskDelegate = ExtractUsingNative7zip ;
886920 #endif
887921
888922 // Execute method delegate for the extractor
@@ -1018,7 +1052,7 @@ protected virtual async Task StartPackageInstallationInner(List<GameInstallPacka
10181052 }
10191053
10201054 #if USENEWZIPDECOMPRESS
1021- private async Task ExtractUsingNativeZip ( GameInstallPackage asset )
1055+ private async Task ExtractUsingManagedZip ( GameInstallPackage asset )
10221056 {
10231057 int threadCounts = ThreadCount ;
10241058
@@ -1037,8 +1071,7 @@ private async Task ExtractUsingNativeZip(GameInstallPackage asset)
10371071 IEnumerable < IEnumerable < int > > zipEntriesChunks = zipEntries . Chunk ( entriesChunk ) ;
10381072
10391073 // Run the workers
1040- await Parallel . ForEachAsync (
1041- zipEntriesChunks , new ParallelOptions
1074+ await Parallel . ForEachAsync ( zipEntriesChunks , new ParallelOptions
10421075 {
10431076 CancellationToken = Token . Token
10441077 } ,
@@ -1047,12 +1080,12 @@ await Parallel.ForEachAsync(
10471080 await using Stream fs = GetSingleOrSegmentedDownloadStream ( asset ) ;
10481081 using var zipArchive = ZipArchive . Open ( fs ) ;
10491082 List < ZipArchiveEntry > entries = zipArchive . Entries . ToList ( ) ;
1050- await ExtractUsingNativeZipWorker ( entry , entries , token ) ;
1083+ await ExtractUsingManagedZipWorker ( entry , entries , token ) ;
10511084 } ) ;
10521085 }
10531086
1054- private async Task ExtractUsingNativeZipWorker ( IEnumerable < int > entriesIndex , List < ZipArchiveEntry > entries ,
1055- CancellationToken cancellationToken )
1087+ private async Task ExtractUsingManagedZipWorker ( IEnumerable < int > entriesIndex , List < ZipArchiveEntry > entries ,
1088+ CancellationToken cancellationToken )
10561089 {
10571090 byte [ ] buffer = GC . AllocateUninitializedArray < byte > ( BufferBigLength ) ;
10581091
@@ -1139,7 +1172,7 @@ void StartWriteInner(byte[] bufferInner, FileStream outputStream, Stream entrySt
11391172 }
11401173 #endif
11411174
1142- private async Task ExtractUsing7zip ( GameInstallPackage asset )
1175+ private async Task ExtractUsingNative7zip ( GameInstallPackage asset )
11431176 {
11441177 // Start Async Thread
11451178 // Since the ArchiveFile (especially with the callbacks) can't run under
0 commit comments