Skip to content

Commit

Permalink
Update AssetComponentUpdate.cs
Browse files Browse the repository at this point in the history
修复在空包状态下连续对同一个分包检查更新的IO冲突
  • Loading branch information
mister91jiao authored Aug 8, 2023
1 parent 08b24dd commit 91e50d1
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions BundleMasterRuntime/AssetComponentUpdate.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using System;
using System.IO;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using ET;
using UnityEngine.Networking;

Expand Down Expand Up @@ -90,9 +91,8 @@ public static async ETTask<UpdateBundleDataInfo> CheckAllBundlePackageUpdate(Dic
{
CreateUpdateLogFile(crcLogPath, null);
}
StreamWriter crcStream = new StreamWriter(crcLogPath, true);
crcStream.AutoFlush = false;
updateBundleDataInfo.PackageCRCFile.Add(bundlePackageName, crcStream);
//把CRCLogPath的分包名存起来
updateBundleDataInfo.PackageCRCFile.Add(bundlePackageName, null);
//获取本地的VersionLog
string localVersionLogExistPath = BundleFileExistPath(bundlePackageName, "VersionLogs.txt", true);
ETTask logTcs = ETTask.Create();
Expand Down Expand Up @@ -136,19 +136,14 @@ public static async ETTask<UpdateBundleDataInfo> CheckAllBundlePackageUpdate(Dic
}
else
{
//不需要更新,关闭CRC文件写入流
foreach (StreamWriter sw in updateBundleDataInfo.PackageCRCFile.Values)
{
sw.Close();
sw.Dispose();
}
//如果不需要更新就清理CRC路径
updateBundleDataInfo.PackageCRCFile.Clear();
}
return updateBundleDataInfo;
}

/// <summary>
/// 获取所哟需要更新的Bundle的文件(不检查文件CRC)
/// 获取所有需要更新的Bundle的文件(不检查文件CRC)
/// </summary>
private static async ETTask CalcNeedUpdateBundle(UpdateBundleDataInfo updateBundleDataInfo, string bundlePackageName, string[] remoteVersionData, string[] localVersionData)
{
Expand Down Expand Up @@ -394,6 +389,15 @@ public static async ETTask DownLoadUpdate(UpdateBundleDataInfo updateBundleDataI
AssetLogHelper.LogError("AssetLoadMode != AssetLoadMode.Build 不需要更新");
return;
}
//打开CRCLog文件
List<string> bundlePackageNames = updateBundleDataInfo.PackageCRCFile.Keys.ToList();
foreach (string bundlePackageName in bundlePackageNames)
{
string crcLogPath = Path.Combine(AssetComponentConfig.HotfixPath, bundlePackageName, "CRCLog.txt");
StreamWriter crcStream = new StreamWriter(crcLogPath, true);
crcStream.AutoFlush = false;
updateBundleDataInfo.PackageCRCFile[bundlePackageName] = crcStream;
}
Dictionary<string, Queue<DownLoadTask>> packageDownLoadTask = new Dictionary<string, Queue<DownLoadTask>>();
ETTask downLoading = ETTask.Create();
//准备需要下载的内容的初始化信息
Expand Down Expand Up @@ -495,4 +499,4 @@ public static async ETTask DownLoadUpdate(UpdateBundleDataInfo updateBundleDataI

}

}
}

0 comments on commit 91e50d1

Please sign in to comment.