Exemplo n.º 1
0
        public async Task <IActionResult> StartUpdate()
        {
            var result = _updateService.CheckForUpdate();

            if (result.IsUpdateAvailable)
            {
                await _updateService.DownloadZipAsync(result);

                await _updateService.UpdateServerAsync();

                return(Ok(true));
            }

            return(Ok(false));
        }
Exemplo n.º 2
0
        public override async Task RunJobAsync()
        {
            try
            {
                await LogInformation("Contacting Github now to see if new version is available.");

                var update = _updateService.CheckForUpdate(Settings);
                await LogProgress(20);

                if (update.IsUpdateAvailable && Settings.AutoUpdate)
                {
                    await LogInformation($"New version found: v{update.AvailableVersion}");
                    await LogInformation($"Auto update is enabled so going to update the server now!");

                    await _settingsService.SetUpdateInProgressSettingAsync(true);

                    await HubHelper.BroadcastUpdateState(true);

                    Task.WaitAll(_updateService.DownloadZipAsync(update));
                    await LogProgress(50);

                    await _updateService.UpdateServerAsync();

                    await _settingsService.SetUpdateInProgressSettingAsync(false);

                    await HubHelper.BroadcastUpdateFinished(true);
                }
                else if (update.IsUpdateAvailable)
                {
                    await LogInformation($"New version found: v{update.AvailableVersion}");
                    await LogInformation("Auto updater is disabled, so going to end the job now.");
                }
                else
                {
                    await LogInformation("No new version available");
                }
            }
            catch (Exception)
            {
                await _settingsService.SetUpdateInProgressSettingAsync(false);

                await HubHelper.BroadcastUpdateState(false);

                await HubHelper.BroadcastUpdateFinished(false);

                throw;
            }
        }