少年修仙传客户端代码仓库
client_linchunjie
2018-09-07 6a2799f5f67c5a399aea2426797482077ef3cf52
Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
1个文件已修改
53 ■■■■■ 已修改文件
System/AssetVersion/RemoteFile.cs 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/AssetVersion/RemoteFile.cs
@@ -11,25 +11,30 @@
public class RemoteFile
{
    static bool m_ProcessErroring = false;
    public static bool processErroring {
    public static bool processErroring
    {
        get { return m_ProcessErroring; }
    }
    public static int maxDownLoadTask = 48;
    public static int MaxConnectLimit = 48;
    static int gDownloadIsRunningCount;
    public static int DownloadIsRunningCount {
    public static int DownloadIsRunningCount
    {
        get { return gDownloadIsRunningCount; }
    }
    public static int gStartTickcount = 0;
    static long gTotalDownloadSize = 0L;  //已下载的字节数
    static object lockObj = new object();
    public static long TotalDownloadedSize {
        get {
    public static long TotalDownloadedSize
    {
        get
        {
            return System.Threading.Interlocked.Read(ref gTotalDownloadSize);
        }
        set {
        set
        {
            gTotalDownloadSize = value;
        }
    }
@@ -37,8 +42,10 @@
    static float downloadSpeedRef = 0f; //字节/秒
    static long downloadSizeRef = 0L;
    public static string DownloadSpeed {
        get {
    public static string DownloadSpeed
    {
        get
        {
            float speed = downloadSpeedRef;
            if (RemoteFile.gStartTickcount != 0)
            {
@@ -95,14 +102,17 @@
    Action<bool, AssetVersion> onCompleted;
    protected bool mHadError = false;
    public bool HaveError {
    public bool HaveError
    {
        get { return mHadError; }
    }
    bool m_Done = false;
    public bool done {
    public bool done
    {
        get { return m_Done; }
        private set {
        private set
        {
            m_Done = value;
            if (value)
            {
@@ -407,8 +417,8 @@
            if (localFileSize == mRemoteFileSize && !outDated)
            {
                gDownloadIsRunningCount--;
                done = true;
                mHadError = !Move(mLocalFileTemp, localFile);//把临时文件改名为正式文件
                done = true;
                yield break; // We already have the file, early out
            }
            else if (localFileSize > mRemoteFileSize || outDated)
@@ -620,6 +630,7 @@
            yield return null;
        }
        if (fileRequest != null)
        {
            fileRequest.Abort();
@@ -633,18 +644,19 @@
                fileResponse.Close();
                fileResponse = null;
            }
            gDownloadIsRunningCount--;
            mHadError = true;
            done = true;
            gDownloadIsRunningCount--;
            yield break;
        }
        try
        {
            FileInfo localTempFileInfo = new FileInfo(mLocalFileTemp);
            if (localTempFileInfo.Exists)
            { //临时文件存在,需要判断大小是否一致
              //判断临时文件和远程文件size是否一致
#if !UNITY_WEBPLAYER
                if (localTempFileInfo.Length != mRemoteFileSize && mRemoteFileSize != 0L)
                {
                    mHadError = true;
@@ -654,15 +666,10 @@
                {  //大小一致 
                    mHadError = !Move(mLocalFileTemp, localFile);//把临时文件改名为正式文件
                }
                gDownloadIsRunningCount--;
                done = true;
#endif
            }
            else
            { //临时文件不存在
                mHadError = true;
                gDownloadIsRunningCount--;
                done = true;
            }
#endif
        }
@@ -671,10 +678,16 @@
            DebugEx.LogError(ex);
            mHadError = true;
        }
        yield return null;
        gDownloadIsRunningCount--;
        done = true;
    }
    bool IsOutdated {
        get {
    bool IsOutdated
    {
        get
        {
            if (File.Exists(mLocalFileTemp))
                return mRemoteLastModified > mLocalLastModified;
            return false;