private async Task <Tool> ExtractAsync(ToolSettings toolSettings) { var tool = ToolUtility.GetLatestToolOrNull(_settings, toolSettings); if (tool == null) { throw new TorSharpException( $"No version of {toolSettings.Name} was found under {_settings.ZippedToolsDirectory}."); } await ExtractToolAsync(tool, _settings.ReloadTools).ConfigureAwait(false); PermissionsUtility.MakeExecutable(_settings, tool.ExecutablePath); return(tool); }
private async Task <ToolUpdate> CheckForUpdateAsync( ToolSettings toolSettings, IFileFetcher fetcher, bool useExistingTools) { var latestLocal = ToolUtility.GetLatestToolOrNull(_settings, toolSettings); if (useExistingTools && latestLocal != null) { return(null); } EnableSecurityProtocols(); var latestDownload = await fetcher.GetLatestAsync().ConfigureAwait(false); var fileExtension = ArchiveUtility.GetFileExtension(latestDownload.Format); var fileName = $"{toolSettings.Prefix}{latestDownload.Version}{fileExtension}"; var destinationPath = Path.Combine(_settings.ZippedToolsDirectory, fileName); ToolUpdateStatus status; if (latestLocal == null) { status = ToolUpdateStatus.NoLocalVersion; } else if (!File.Exists(destinationPath)) { status = ToolUpdateStatus.NewerVersionAvailable; } else { status = ToolUpdateStatus.NoUpdateAvailable; } return(new ToolUpdate( status, latestLocal?.Version, destinationPath, latestDownload)); }