Esempio n. 1
0
        private static void UnzipBackendStep(Dictionary <string, ResPack> dict, string fileKey,
                                             Action <Dictionary <string, ResPack> > onUnzipComplete)
        {
            ResPack resPack  = dict[fileKey];
            string  filePath = AssetLoader.ExternalDownloadPath + "/" + resPack.downloadPath;

            Loom.RunAsync(() =>
            {
                try
                {
                    ZipUtil.UnzipThread(filePath, AssetLoader.ExternalHotfixPath + "/" + resPack.releasePath);
                }
                catch (IOException e)
                {
                    Debug.LogException(e);
                }

                Loom.QueueOnMainThread(() =>
                {
                    File.Delete(filePath);
                    FileMark fm = new FileMark(AssetLoader.ExternalHotfixPath, ResPath.Backend + "_" + fileKey);
                    fm.UpdateRecord(AppConfig.Instance.version + "");

                    onUnzipComplete?.Invoke(dict);
                });
            });
        }
Esempio n. 2
0
        /// <summary>
        /// 删除热更文件
        /// </summary>
        /// <param name="onDelete"></param>
        public void DeleteHotfixDir(Action <bool> onDelete)
        {
            FileMark fileMark = new FileMark(Application.persistentDataPath, FileChecker.DeleteHotfixMark);

            fileMark.Delete();

            DirectoryInfo dir = new DirectoryInfo(AssetLoader.ExternalHotfixPath);

            if (dir.Exists)
            {
                try
                {
                    dir.Delete(true);
                    onDelete?.Invoke(true);
                }
                catch (Exception e)
                {
                    onDelete?.Invoke(false);

                    fileMark.UpdateRecord("true");

                    BuglyAgent.ReportException("DeleteHotfixDir", e.Message, e.StackTrace);
                    PopupManager.ShowAlertWindow(I18NManager.Get("Update_RepairFail"), null,
                                                 I18NManager.Get("Update_RepairCloseGame")).WindowActionCallback = evt =>
                    {
                        Application.Quit();
                    };
                }
            }
            else
            {
                onDelete?.Invoke(true);
            }
        }
Esempio n. 3
0
        private static void OnCompleteFullLoading(DownloadItem downloadItem)
        {
            Loom.RunAsync(() =>
            {
                if (downloadItem.FileType == FileType.Zip)
                {
                    try
                    {
                        ZipUtil.UnzipThread(downloadItem.LocalPath,
                                            AssetLoader.ExternalHotfixPath + "/" + _releasePath);
                    }
                    catch (IOException e)
                    {
                        Debug.LogException(e);
                    }
                }

                Loom.QueueOnMainThread(() =>
                {
                    File.Delete(downloadItem.LocalPath);
                    if (_tag == ResPath.AllResources)
                    {
                        //下载完所有资源标记下载
                        PlayerPrefs.SetInt(UpdateController.LastVersionKey, AppConfig.Instance.version);
                        MarkDownloadAll();
                    }
                    else if (_tag == ResPath.AppStart)
                    {
                        FileMark fm = new FileMark(AssetLoader.ExternalHotfixPath, ResPath.AppStart);
                        fm.UpdateRecord(AppConfig.Instance.version + "");
                    }
                    else if (_tag == ResPath.Extend)
                    {
                        FileMark fm = new FileMark(AssetLoader.ExternalHotfixPath, ResPath.Backend);
                        fm.UpdateRecord(AppConfig.Instance.version + "");
                    }

                    if (timerHandler != null)
                    {
                        ClientTimer.Instance.RemoveCountDown(timerHandler);
                    }

                    _onComplete?.Invoke(_tag);
                });
            });

            if (downloadItem.FileType == FileType.Zip)
            {
                timerHandler = ClientTimer.Instance.AddCountDown("Upzip", Int64.MaxValue, 0.1f,
                                                                 val =>
                {
                    int progress = (int)((float)ZipUtil.CurrentSize / ZipUtil.TotalSize * 100);
                    LoadingProgress.Instance.SetPercent(progress, true);
                }, null);
            }
        }
        private static void MarkDownloadAll()
        {
            FileMark fm = new FileMark(AssetLoader.ExternalHotfixPath, ResPath.AllResources);

            fm.UpdateRecord(AppConfig.Instance.version + "");
        }