public void ClearUnusedFiles() { List <string> filesToRemove = new List <string>(); foreach (string dir in Directory.EnumerateDirectories(PathRouter.SandboxPath)) { foreach (string file in Directory.EnumerateFiles(dir, "*.*", SearchOption.AllDirectories)) { string path = PathRouter.NormalizePath(file); string name = path.Remove(0, PathRouter.SandboxPath.Length); if (!manifest.query.ContainsKey(name)) { filesToRemove.Add(path); } } } foreach (string file in filesToRemove) { File.Delete(file); string name = file.Remove(0, PathRouter.SandboxPath.Length); sandboxFiles.Remove(name); HotfixLog.Log("Remove unused file: " + name); } }
async Task ScatterUpdate() { byte[] data = await Download(PathRouter.FileManifest); data = FileLoader.RemoveBOM(data); newFileManifest = JsonUtility.FromJson <FileManifest>(Encoding.UTF8.GetString(data)); newFileManifest.BuildQuery(); HotfixLog.LogFormat("Manifest(new), files: {0}", newFileManifest.files.Count); var updateFiles = fileManager.CalculateUpdateFiles(newFileManifest); foreach (string name in updateFiles) { HotfixLog.Log("Update file: " + name); string file = PathRouter.SandboxPath + name; string downloadFile = file + ".download"; Directory.CreateDirectory(Path.GetDirectoryName(file)); try { await DownloadToFile(name, downloadFile); File.Delete(file); File.Move(downloadFile, file); fileManager.AddFile(name); } catch (Exception e) { File.Delete(downloadFile); throw e; } } }
protected override async Task AsyncInit() { if (ResourceSystem.ResMode == ResourceSystem.Mode.Dev) { HotfixLog.Log("Skip hotfix process in Dev mode"); return; } HotfixLog.Log("SandboxExpireCheck"); SandboxExpireCheck(); HotfixLog.Log("InitVersion"); InitVersion(); if (version.Cdn.Contains("skip-update")) { HotfixLog.Log("Skip hotfix since this package is marked as 'skip-update'"); return; } HotfixLog.Log("NewVersionCheck"); var verCheckRet = await NewVersionCheck(); HotfixLog.Log("NewVersionCheck result: " + verCheckRet); if (verCheckRet == VersionCheckResult.AppUpdate) { // TODO: notify user and direct to app store // IMPORTANT: In most cases termination of application under iOS should be left at the user discretion. Consult Apple Technical Page qa1561 for further details. HotfixLog.LogFormat( "App update required, {0} -> {1}", version, newVersion); if (Application.isEditor) { throw new Exception(); } else { Application.Quit(); } } HotfixLog.Log("ScatterUpdate"); await ScatterUpdate(); HotfixLog.Log("ApplyNewVersion"); ApplyNewVersion(); HotfixLog.Log("ClearUnusedFiles"); Instance.fileManager.ClearUnusedFiles(); HotfixLog.Log("Done"); }
public HotfixSystem() { var p = Application.platform; if (p == RuntimePlatform.WindowsEditor || p == RuntimePlatform.Android) { platform = "Android"; } else if (p == RuntimePlatform.OSXEditor || p == RuntimePlatform.IPhonePlayer) { platform = "iOS"; } HotfixLog.Log("Platform: " + platform); }
public static void Start() { HotfixLog.Log("Hello ILRuntime World"); Demo.Instance.Start(); }