Example #1
0
        void IFsmNode.OnEnter()
        {
            PatchEventDispatcher.SendPatchStatesChangeMsg(EPatchStates.CheckSandboxDirty);

            string appVersion = PatchManager.Instance.GetAPPVersion();
            string filePath   = PatchHelper.GetSandboxStaticFilePath();

            // 记录APP版本信息到静态文件
            if (PatchHelper.CheckSandboxStaticFileExist() == false)
            {
                PatchHelper.Log(ELogLevel.Log, $"Create sandbox static file : {filePath}");
                FileUtility.CreateFile(filePath, appVersion);
                _patcher.SwitchNext();
                return;
            }

            // 每次启动时比对APP版本号是否一致
            string recordVersion = FileUtility.ReadFile(filePath);

            // 如果记录的版本号不一致
            if (recordVersion != appVersion)
            {
                PatchHelper.Log(ELogLevel.Warning, $"Sandbox is dirty, Record version is {recordVersion}, APP version is {appVersion}");
                PatchHelper.Log(ELogLevel.Warning, "Clear all sandbox files.");
                PatchHelper.ClearSandbox();
                _patcher.SwitchLast();
            }
            else
            {
                _patcher.SwitchNext();
            }
        }