1- using System ;
1+ using System ;
22using System . IO ;
33using System . Collections . Generic ;
44using System . Globalization ;
5+ using System . Linq ;
56using ET ;
67using UnityEngine . Networking ;
78
@@ -90,9 +91,8 @@ public static async ETTask<UpdateBundleDataInfo> CheckAllBundlePackageUpdate(Dic
9091 {
9192 CreateUpdateLogFile ( crcLogPath , null ) ;
9293 }
93- StreamWriter crcStream = new StreamWriter ( crcLogPath , true ) ;
94- crcStream . AutoFlush = false ;
95- updateBundleDataInfo . PackageCRCFile . Add ( bundlePackageName , crcStream ) ;
94+ //把CRCLogPath的分包名存起来
95+ updateBundleDataInfo . PackageCRCFile . Add ( bundlePackageName , null ) ;
9696 //获取本地的VersionLog
9797 string localVersionLogExistPath = BundleFileExistPath ( bundlePackageName , "VersionLogs.txt" , true ) ;
9898 ETTask logTcs = ETTask . Create ( ) ;
@@ -136,19 +136,14 @@ public static async ETTask<UpdateBundleDataInfo> CheckAllBundlePackageUpdate(Dic
136136 }
137137 else
138138 {
139- //不需要更新,关闭CRC文件写入流
140- foreach ( StreamWriter sw in updateBundleDataInfo . PackageCRCFile . Values )
141- {
142- sw . Close ( ) ;
143- sw . Dispose ( ) ;
144- }
139+ //如果不需要更新就清理CRC路径
145140 updateBundleDataInfo . PackageCRCFile . Clear ( ) ;
146141 }
147142 return updateBundleDataInfo ;
148143 }
149144
150145 /// <summary>
151- /// 获取所哟需要更新的Bundle的文件 (不检查文件CRC)
146+ /// 获取所有需要更新的Bundle的文件 (不检查文件CRC)
152147 /// </summary>
153148 private static async ETTask CalcNeedUpdateBundle ( UpdateBundleDataInfo updateBundleDataInfo , string bundlePackageName , string [ ] remoteVersionData , string [ ] localVersionData )
154149 {
@@ -394,6 +389,15 @@ public static async ETTask DownLoadUpdate(UpdateBundleDataInfo updateBundleDataI
394389 AssetLogHelper . LogError ( "AssetLoadMode != AssetLoadMode.Build 不需要更新" ) ;
395390 return ;
396391 }
392+ //打开CRCLog文件
393+ List < string > bundlePackageNames = updateBundleDataInfo . PackageCRCFile . Keys . ToList ( ) ;
394+ foreach ( string bundlePackageName in bundlePackageNames )
395+ {
396+ string crcLogPath = Path . Combine ( AssetComponentConfig . HotfixPath , bundlePackageName , "CRCLog.txt" ) ;
397+ StreamWriter crcStream = new StreamWriter ( crcLogPath , true ) ;
398+ crcStream . AutoFlush = false ;
399+ updateBundleDataInfo . PackageCRCFile [ bundlePackageName ] = crcStream ;
400+ }
397401 Dictionary < string , Queue < DownLoadTask > > packageDownLoadTask = new Dictionary < string , Queue < DownLoadTask > > ( ) ;
398402 ETTask downLoading = ETTask . Create ( ) ;
399403 //准备需要下载的内容的初始化信息
@@ -495,4 +499,4 @@ public static async ETTask DownLoadUpdate(UpdateBundleDataInfo updateBundleDataI
495499
496500 }
497501
498- }
502+ }
0 commit comments