/// <summary>
        /// 处理沙盒被污染
        /// 注意:在覆盖安装的时候,会保留沙盒目录里的文件,所以需要强制清空。
        /// </summary>
        private void ProcessSandboxDirty()
        {
            string appVersion = PatchManager.Instance.GetAPPVersion();
            string filePath   = PatchHelper.GetSandboxStaticFilePath();

            // 如果是首次打开,记录APP版本信息
            if (PatchHelper.CheckSandboxStaticFileExist() == false)
            {
                MotionLog.Log($"Create sandbox static file : {filePath}");
                FileUtility.CreateFile(filePath, appVersion);
                return;
            }

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

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

                // 重新写入最新的APP版本信息
                MotionLog.Log($"Recreate sandbox static file : {filePath}");
                FileUtility.CreateFile(filePath, appVersion);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 清空缓存并删除所有缓存文件
 /// </summary>
 public void ClearCache()
 {
     MotionLog.Warning("Clear cache and remove all sandbox files.");
     CacheAppVersion = string.Empty;
     CachedFileHashList.Clear();
     PatchHelper.ClearSandbox();
 }
Beispiel #3
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();
            }
        }
Beispiel #4
0
 /// <summary>
 /// 清空缓存并删除所有缓存文件
 /// </summary>
 public void ClearCache()
 {
     MotionLog.Warning("Clear cache and remove all sandbox files.");
     CacheVersion    = string.Empty;
     ResourceVersion = DEFAULT_VERSION;
     CachedFileHashList.Clear();
     PatchHelper.ClearSandbox();
 }
        /// <summary>
        /// 修复客户端
        /// </summary>
        public void FixClient()
        {
            // 清空缓存
            PatchHelper.ClearSandbox();

            // 重启游戏
#if UNITY_EDITOR
            UnityEditor.EditorApplication.isPlaying = false;
#else
            Application.Quit();
#endif
        }