少年修仙传客户端代码仓库
client_Wu Xijin
2018-08-27 929f63bbd339d2219a25ad44228cd6ecf80d3136
2956  加固资源下载,在下载完成文件后进行文件校验
4个文件已修改
81 ■■■■■ 已修改文件
System/AssetVersion/AssetVersion.cs 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/AssetVersion/AssetVersionUtility.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/AssetVersion/DownLoadAndDiscompressTask.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/MainInterfacePanel/TipPanel.cs 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/AssetVersion/AssetVersion.cs
@@ -93,36 +93,46 @@
        }
    }
    public bool CheckLocalFileValid()
    public bool CheckLocalFileValid(bool _completeFile)
    {
        if (extersion == ".manifest" || extersion == ".bytes" || extersion == ".txt" || extersion == ".dll")
        if (_completeFile)
        {
            var path = StringUtility.Contact(ResourcesPath.Instance.ExternalStorePath, m_RelativePath);
            var fileInfo = new FileInfo(path);
            if (!fileInfo.Exists || fileInfo.Length != size || md5 != FileExtersion.GetMD5HashFromFile(path))
            {
                return false;
            }
        }
        else if (string.IsNullOrEmpty(extersion) || extersion.Length == 0)
        {
            var path = StringUtility.Contact(ResourcesPath.Instance.ExternalStorePath, m_RelativePath);
            var fileInfo = new FileInfo(path);
            var manifestAssetVersion = AssetVersionUtility.GetAssetVersion(StringUtility.Contact(m_RelativePath, ".manifest"));
            if (!fileInfo.Exists || fileInfo.Length != size || manifestAssetVersion == null || !manifestAssetVersion.CheckLocalFileValid())
            {
                return false;
            }
            return fileInfo.Exists && fileInfo.Length == size && md5 == FileExtersion.GetMD5HashFromFile(path);
        }
        else
        {
            var path = StringUtility.Contact(ResourcesPath.Instance.ExternalStorePath, m_RelativePath);
            var fileInfo = new FileInfo(path);
            if (!fileInfo.Exists || fileInfo.Length != size)
            if (extersion == ".manifest" || extersion == ".bytes" || extersion == ".txt" || extersion == ".dll")
            {
                return false;
                var path = StringUtility.Contact(ResourcesPath.Instance.ExternalStorePath, m_RelativePath);
                var fileInfo = new FileInfo(path);
                if (!fileInfo.Exists || fileInfo.Length != size || md5 != FileExtersion.GetMD5HashFromFile(path))
                {
                    return false;
                }
            }
            else if (string.IsNullOrEmpty(extersion) || extersion.Length == 0)
            {
                var path = StringUtility.Contact(ResourcesPath.Instance.ExternalStorePath, m_RelativePath);
                var fileInfo = new FileInfo(path);
                var manifestAssetVersion = AssetVersionUtility.GetAssetVersion(StringUtility.Contact(m_RelativePath, ".manifest"));
                if (!fileInfo.Exists || fileInfo.Length != size || manifestAssetVersion == null || !manifestAssetVersion.CheckLocalFileValid(false))
                {
                    return false;
                }
            }
            else
            {
                var path = StringUtility.Contact(ResourcesPath.Instance.ExternalStorePath, m_RelativePath);
                var fileInfo = new FileInfo(path);
                if (!fileInfo.Exists || fileInfo.Length != size)
                {
                    return false;
                }
            }
        }
System/AssetVersion/AssetVersionUtility.cs
@@ -91,7 +91,7 @@
            {
                foreach (var assetVersion in assetVersions.Values)
                {
                    if (!assetVersion.CheckLocalFileValid())
                    if (!assetVersion.CheckLocalFileValid(false))
                    {
                        if (assetVersion.IsPriorAsset())
                        {
System/AssetVersion/DownLoadAndDiscompressTask.cs
@@ -3,6 +3,7 @@
using UnityEngine;
using System;
using Snxxz.UI;
using System.Threading;
public class DownLoadAndDiscompressTask : Singleton<DownLoadAndDiscompressTask>
{
@@ -124,8 +125,14 @@
    private void OnFileDownLoadCompleted(bool _ok, AssetVersion _assetVersion)
    {
        var correctFile = false;
        if (_ok)
        {
            correctFile = _assetVersion.CheckLocalFileValid(true);
        }
        if (_ok && correctFile)
        {
            okCount++;
            _assetVersion.localValid = true;
        }
System/MainInterfacePanel/TipPanel.cs
@@ -89,13 +89,27 @@
                {
                    if (InGameDownLoad.Instance.CheckDominantDownLoad())
                    {
                        if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
                        if (InGameDownTestUtility.enable)
                        {
                            InGameDownLoad.Instance.TryDownLoad(InGameDownLoad.Dominant.Half);
                            if (InGameDownTestUtility.isWifi)
                            {
                                InGameDownLoad.Instance.TryDownLoad(InGameDownLoad.Dominant.Half);
                            }
                            else
                            {
                                InGameDownLoad.Instance.TryDownLoad(InGameDownLoad.Dominant.Whole);
                            }
                        }
                        else
                        {
                            InGameDownLoad.Instance.TryDownLoad(InGameDownLoad.Dominant.Whole);
                            if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
                            {
                                InGameDownLoad.Instance.TryDownLoad(InGameDownLoad.Dominant.Half);
                            }
                            else
                            {
                                InGameDownLoad.Instance.TryDownLoad(InGameDownLoad.Dominant.Whole);
                            }
                        }
                    }
                }