Example #1
0
        private List <ABUnit> CalculateDeleteList(AssetDataTable local, AssetDataTable remote)
        {
            if (remote == null || local == null)
            {
                return(null);
            }

            var remoteABList = remote.GetAllABUnit();

            //防止远程清单文件下载失败导致本地被删光
            if (remoteABList.Count == 0)
            {
                return(null);
            }

            List <ABUnit> localABList = local.GetAllABUnit();

            List <ABUnit> deleteABList = new List <ABUnit>();

            for (int i = localABList.Count - 1; i >= 0; --i)
            {
                ABUnit localABUnit  = localABList[i];
                ABUnit remoteABUnit = remote.GetABUnit(localABUnit.abName);

                if (remoteABUnit == null)
                {
                    deleteABList.Add(localABUnit);
                    continue;
                }
            }

            return(deleteABList);
        }
Example #2
0
        private void ProcessRemoteABConfig(HotUpdateRes res)
        {
            AssetDataTable remoteDataTable = new AssetDataTable();

            try
            {
                remoteDataTable.LoadPackageFromFile(res.localResPath);
            }
            catch (Exception e)
            {
                Log.e(e);
            }
            m_NeedUpdateFileList = ABUnitHelper.CalculateLateList(AssetDataTable.S, remoteDataTable, true);

            if (m_NeedUpdateFileList != null)
            {
                if (m_Package.updateBlackList != null)
                {
                    var list = m_Package.updateBlackList;

                    for (int i = 0; i < list.Count; ++i)
                    {
                        for (int j = m_NeedUpdateFileList.Count - 1; j >= 0; --j)
                        {
                            if (m_NeedUpdateFileList[j].abName.Equals(list[i]))
                            {
                                m_NeedUpdateFileList.RemoveAt(j);
                                break;
                            }
                        }
                    }
                }

                m_NeedUpdateFileCount = m_NeedUpdateFileList.Count;

                for (int i = 0; i < m_NeedUpdateFileCount; ++i)
                {
                    m_NeedUpdateFileSize += m_NeedUpdateFileList[i].fileSize;
                }
            }

            //Dump();
            ClearLoader();
        }
Example #3
0
        private void ProcessNewInstall()
        {
            bool isNewInstall = CheckIsNewInstall();

            Log.i("Check Is New Install:" + isNewInstall);

            if (isNewInstall)
            {
                //对比外部文件
                List <string> outResult = new List <string>();
                FilePath.GetFileInFolder(FilePath.persistentDataPath4Res, ProjectPathConfig.abConfigfileName, outResult);

                AssetDataTable exterTable = new AssetDataTable();
                for (int i = 0; i < outResult.Count; ++i)
                {
                    exterTable.LoadPackageFromFile(outResult[i]);
                }

                //生成差异文件列表:
                List <ABUnit> needDeleteList = ABUnitHelper.CalculateLateList(exterTable, AssetDataTable.S, false);

                for (int i = 0; i < needDeleteList.Count; ++i)
                {
                    ABUnit unit          = needDeleteList[i];
                    string exterFilePath = ProjectPathConfig.AssetBundleName2ExterUrl(unit.abName);
                    if (File.Exists(exterFilePath))
                    {
                        File.Delete(exterFilePath);
                    }
                }

                var packages = AssetDataTable.S.allAssetDataPackages;
                if (packages.Count > 0)
                {
                    var package = packages[0];
                    PlayerPrefs.SetString(INNER_RES_PACKAGE, package.key);
                    PlayerPrefs.SetInt(INNER_RES_BUILDTIME, (int)package.buildTime);
                    PlayerPrefs.Save();
                }
            }
        }
Example #4
0
        //计算成成更新的资源列表
        public static List <ABUnit> CalculateLateList(AssetDataTable oldData, AssetDataTable newData, bool addNew)
        {
            if (newData == null || oldData == null)
            {
                return(null);
            }

            List <ABUnit> newABUnitList = newData.GetAllABUnit();

            List <ABUnit> lateABList = new List <ABUnit>();

            for (int i = newABUnitList.Count - 1; i >= 0; --i)
            {
                ABUnit newUnit = newABUnitList[i];
                ABUnit oldUnit = oldData.GetABUnit(newUnit.abName);

                if (oldUnit == null)
                {
                    //更新的新资源
                    if (addNew)
                    {
                        lateABList.Add(newUnit);
                    }
                    continue;
                }

                if (oldUnit.md5.Equals(newUnit.md5))
                {
                    continue;
                }

                if (oldUnit.buildTime < newUnit.buildTime)
                {
                    lateABList.Add(newUnit);
                }
            }

            return(lateABList);
        }
Example #5
0
        public void ModifyAssetDataTable(AssetDataTable table)
        {
            RecordCell       cell    = null;
            AssetDataPackage package = null;

            for (int i = 0; i < m_UpdateRecordList.Count; ++i)
            {
                cell = m_UpdateRecordList[i];
                ABUnit unit = table.GetABUnit(cell.name);
                if (unit == null)
                {
                    table.AddAssetBundleName(cell.name, null, cell.md5, 1, cell.buildTime, out package);
                    continue;
                }
                else
                {
                    unit.buildTime = cell.buildTime;
                    unit.md5       = cell.md5;
                    unit.fileSize  = cell.fileSize;
                }
            }
        }