public void Update(InstallationPackageType type) { this.Find <StackPanel>("DownloadButtons").IsVisible = false; this.Find <StackPanel>("DownloadNotice").IsVisible = true; var fileName = GetInstallationPackageName(type); Task.Run(async() => { if (DownloadInstallationPackage(fileName)) { void StartInstallationAndExit(string installerPath) { // starts a detached process that does not get terminated // when we close Chia Plot Status, as we need to close // it to update the files (on windows and maybe on mac too) var startInfo = new ProcessStartInfo(installerPath); startInfo.UseShellExecute = true; Process.Start(startInfo); Environment.Exit(0); } var paths = GetFullInstallationPackagePath(type); if (File.Exists(paths.Item1)) { StartInstallationAndExit(paths.Item1); return; } if (paths.Item2 != null && File.Exists(paths.Item2)) { StartInstallationAndExit(paths.Item2); return; } else { Debug.WriteLine("Both installation package paths lead nowhere, falling back to manual installation"); } } else { Debug.WriteLine("Download of installation package failed, falling back to manual installation"); } // fallback to manual download via browser Utils.OpenUrl("https://github.com/grayfallstown/Chia-Plot-Status/releases/latest/"); }); }
/** * It was requested to rename Setup.exe in something that contains the name of the application. * Problem is the download url and therefor the file name is hardcoded to Setup.exe. * Old applications would no longer be able to find the update if the name was changed. * Solving this by using a fallback name now and once a few updates passed I can change * the name without breaking too many installations. */ public static (string, string?) GetInstallationPackageName(InstallationPackageType type) { switch (type) { case InstallationPackageType.EXE: return("ChiaPlotStatus.windows-Setup.exe", "Setup.exe"); case InstallationPackageType.DEB: return("ChiaPlotStatus.linux-x64.deb", null); case InstallationPackageType.RPM: return("ChiaPlotStatus.linux-x64.rpm", null); case InstallationPackageType.PKG: return("ChiaPlotStatus.mac.pkg", null); default: throw new NotImplementedException("unknown InstallationPackageType " + type); } }
private async Task <ActionResult> AddQube(AddQubePackageModel model, InstallationPackageType type) { if (!ModelState.IsValid) { return(View("Add", new AddPackageModel { PackageName = model.PackageName, QubePackage = model, })); } try { var files = new List <IFormFile>(new[] { model.PythonInstaller, model.QbConf, model.QubeCoreMsi, model.QubeWorkerMsi }); files.AddRange(model.QubeJobTypeMsis); await CreatePackage( model.PackageName, type, files, model.InstallCommandLine); } catch (Exception ex) { ModelState.AddModelError("", $"Failed to completely create package with error: {ex}"); return(View("Add", new AddPackageModel { PackageName = model.PackageName, QubePackage = model, })); } return(RedirectToAction("Details", new { pkgId = model.PackageName })); }
private async Task CreatePackage( string packageId, InstallationPackageType type, IEnumerable <IFormFile> files, string commandLine = null) { var package = await _packageCoordinator.GetPackage(packageId) ?? new InstallationPackage(packageId, type); try { var container = _blobClient.GetContainerReference(package.Container); if (container != null) { await container.CreateIfNotExistsAsync(); } // Sanitise files as it can contain nulls files = files.Where(f => f != null); foreach (var file in files) { await UploadFileToBlob(file, container); } package.Files.Clear(); package.Files.AddRange(files.Select(f => f.FileName)); package.PackageInstallCommand = commandLine; await _packageCoordinator.UpdatePackage(package); } catch (AggregateException aex) { throw aex.InnerExceptions.First(); } catch (Exception ex) { throw ex; } }
private async Task <ActionResult> AddGeneralPackageImpl(string packageName, AddGeneralPackageModel model, InstallationPackageType type) { if (model.Files == null || !model.Files.Any()) { ModelState.AddModelError("GeneralPackage.Files", $"At least one file must be specified."); } if (!ModelState.IsValid) { return(View("Add", new AddPackageModel { PackageName = packageName, GeneralPackage = model, Type = type, })); } try { await CreatePackage( packageName, type, model.Files, model.InstallCommandLine); } catch (Exception ex) { ModelState.AddModelError("", $"Failed to completely create package with error: {ex}"); return(View("Add", new AddPackageModel { PackageName = packageName, GeneralPackage = model, Type = type, })); } return(RedirectToAction("Details", new { pkgId = packageName })); }
public InstallationPackage(string packageName, InstallationPackageType type) { PackageName = packageName; Type = type; Container = Guid.NewGuid().ToString(); }
private async Task <ActionResult> AddGeneralPackageImpl(AddGeneralPackageModel model, InstallationPackageType type) { if (!ModelState.IsValid) { return(View("Add", new AddPackageModel { PackageName = model.PackageName, GeneralPackage = model, })); } try { await CreatePackage( model.PackageName, type, model.Files, model.InstallCommandLine); } catch (Exception ex) { ModelState.AddModelError("", $"Failed to completely create package with error: {ex}"); return(View("Add", new AddPackageModel { PackageName = model.PackageName, GeneralPackage = model, })); } return(RedirectToAction("Details", new { pkgId = model.PackageName })); }
public static bool HasInstallationCommand(this InstallationPackageType type) { return(type == InstallationPackageType.General || type == InstallationPackageType.Gpu); }