/// <summary> /// Performs the update /// </summary> private bool DoUpdate() { if (!updater.Download()) { if (!updater.Fetch() || !updater.Parse()) { UpdateProgressBar(updater.LastError()); return(false); } UpdateProgressBar("Download of update failed, retrying…"); if (!updater.Download()) { return(false); } } CloseASB(); if (!updater.Extract(applicationPath, UseLocalAppDataForDataFiles)) { UpdateProgressBar("Extracting update files failed, retrying…"); if (!updater.Extract(applicationPath, UseLocalAppDataForDataFiles)) { return(false); } } return(true); }
public async Task Execute(Action <IProgress> progressCallback) { var status = updater.Status(); if (!status.UpToDate) { DownloadResult downloadResult = await updater.Download(status.LatestVersion, (downloadProgress) => { progressCallback(downloadProgress); }); KillProcess(initiatingProcess); InstallResult installResult = updater.Install(status.LatestVersion, (installProcess) => { progressCallback(installProcess); }); if (installResult.IsSuccess) { this.manifest.Application.Version = status.LatestVersion; ISerializer serializer = SerializerFactory.GetInstance(); MethodInfo serializerGetInstance = serializer.GetType().GetMethod("Save"); Type manifestType = manifest.GetType(); MethodInfo genericSerializerGetInstance = serializerGetInstance.MakeGenericMethod(manifestType); genericSerializerGetInstance.Invoke(serializer, new object[] { manifestPath, manifest }); } StartProcess(followUpProcessPath); Environment.Exit(1); } }
/// <summary> /// Performs the update /// </summary> private bool DoUpdate() { if (!updater.Download()) { if (!updater.Fetch() || !updater.Parse()) { UpdateProgressBar(updater.LastError()); return(updater.Cleanup()); } UpdateProgressBar("Download of update failed, retrying..."); if (!updater.Download()) { return(updater.Cleanup()); } } if (executablePath != "") { workingDirectory = Path.GetDirectoryName(executablePath); CloseASB(); } // Test directory else { workingDirectory = Path.Combine(workingDirectory, "test"); executablePath = Path.Combine(workingDirectory, "ARK Smart Breeding.exe"); if (!Directory.Exists(workingDirectory)) { Directory.CreateDirectory(workingDirectory); } } if (!updater.Extract(workingDirectory)) { UpdateProgressBar("Extracting update files failed, retrying..."); if (!updater.Extract(workingDirectory)) { return(updater.Cleanup()); } } return(updater.Cleanup()); }