Пример #1
0
        private void RefreshCheckInfoStatus()
        {
            if (!m_VersionListReady || !m_ReadOnlyListReady || !m_ReadWriteListReady)
            {
                return;
            }

            int  removedCount         = 0;
            int  updateCount          = 0;
            long updateTotalLength    = 0L;
            long updateTotalZipLength = 0L;

            foreach (KeyValuePair <string, CheckInfo> checkInfo in m_CheckInfos)
            {
                CheckInfo ci = checkInfo.Value;
                ci.RefreshStatus();
                if (ci.Status == CheckInfo.CheckStatus.StorageInReadOnly)
                {
                    ProcessResourceInfo(ci.ResourceName, ci.Length, ci.HashCode, true);
                }
                else if (ci.Status == CheckInfo.CheckStatus.StorageInReadWrite)
                {
                    ProcessResourceInfo(ci.ResourceName, ci.Length, ci.HashCode, false);
                }
                else if (ci.Status == CheckInfo.CheckStatus.NeedUpdate)
                {
                    updateCount++;
                    updateTotalLength    += ci.Length;
                    updateTotalZipLength += ci.ZipLength;

                    ResourceNeedUpdate(ci.ResourceName, ci.Length, ci.HashCode, ci.ZipLength, ci.ZipHashCode);
                }
                else if (ci.Status == CheckInfo.CheckStatus.Disuse)
                {
                    // Do nothing.
                }
                else
                {
                    throw new Exception(TextUtil.Format("Check resources '{0}' error with unknown status.", ci.ResourceName));
                }

                if (ci.NeedRemove)
                {
                    removedCount++;
                    string path = PathUtil.GetCombinePath(m_ResourceManager.ReadWritePath, PathUtil.GetResourceNameWithSuffix(ci.ResourceName));
                    File.Delete(path);

                    if (!m_ResourceManager.ReadWriteResourceInfos.ContainsKey(ci.ResourceName))
                    {
                        throw new Exception(TextUtil.Format("Resource '{0}' is not exist in read-write list.", ci.ResourceName));
                    }

                    m_ResourceManager.ReadWriteResourceInfos.Remove(ci.ResourceName);
                }
            }

            ResourceCheckComplete(removedCount, updateCount, updateTotalLength, updateTotalZipLength);
        }
Пример #2
0
        private CheckInfo GetOrAddCheckInfo(string resourceName)
        {
            CheckInfo checkInfo = null;

            if (m_CheckInfos.TryGetValue(resourceName, out checkInfo))
            {
                return(checkInfo);
            }

            checkInfo = new CheckInfo(resourceName);
            m_CheckInfos.Add(checkInfo.ResourceName, checkInfo);

            return(checkInfo);
        }