public IKeychainAdapter LoadFromSystem(UriString host) { Guard.ArgumentNotNull(host, nameof(host)); var keychainAdapter = Connect(host) as KeychainAdapter; var credential = credentialManager.Load(host); if (credential == null) { logger.Warning("Cannot load host from Credential Manager; removing from cache"); Clear(host, false); keychainAdapter = null; } else { keychainAdapter.Set(credential); var connection = GetConnection(host); if (connection.Username == null) { connection.Username = credential.Username; SaveConnectionsToDisk(); } if (credential.Username != connection.Username) { logger.Warning("Keychain Username:\"{0}\" does not match cached Username:\"{1}\"; Hopefully it works", credential.Username, connection.Username); } } return(keychainAdapter); }
public async Task <IKeychainAdapter> Load(UriString host) { Guard.ArgumentNotNull(host, nameof(host)); var keychainAdapter = FindOrCreateAdapter(host); var connection = GetConnection(host); var keychainItem = await credentialManager.Load(host); if (keychainItem == null) { logger.Warning("Cannot load host from Credential Manager; removing from cache"); await Clear(host, false); keychainAdapter = null; } else { if (keychainItem.Username != connection.Username) { logger.Warning("Keychain Username:\"{0}\" does not match cached Username:\"{1}\"; Hopefully it works", keychainItem.Username, connection.Username); } keychainAdapter.Set(keychainItem); } return(keychainAdapter); }
public void Login(string username, string password, Action <LoginResult> need2faCode, Action <bool, string> result) { Guard.ArgumentNotNull(need2faCode, "need2faCode"); Guard.ArgumentNotNull(result, "result"); new FuncTask <LoginResultData>(taskManager.Token, () => loginManager.Login(OriginalUrl, username, password)) .FinallyInUI((success, ex, res) => { if (!success) { logger.Warning(ex); result(false, ex.Message); return; } if (res.Code == LoginResultCodes.CodeRequired) { var resultCache = new LoginResult(res, result, need2faCode); need2faCode(resultCache); } else { result(res.Code == LoginResultCodes.Success, res.Message); } }) .Start(); }
private bool IsGitExtracted() { if (!installDetails.GitInstallationPath.DirectoryExists()) { Logger.Warning($"{installDetails.GitInstallationPath} does not exist"); return(false); } var gitExecutableMd5 = environment.FileSystem.CalculateFileMD5(installDetails.GitExecutablePath); var expectedGitExecutableMd5 = environment.IsWindows ? GitInstallDetails.WindowsGitExecutableMD5 : GitInstallDetails.MacGitExecutableMD5; if (!expectedGitExecutableMd5.Equals(gitExecutableMd5, StringComparison.InvariantCultureIgnoreCase)) { Logger.Warning($"Path {installDetails.GitExecutablePath} has MD5 {gitExecutableMd5} expected {expectedGitExecutableMd5}"); return(false); } var gitLfsExecutableMd5 = environment.FileSystem.CalculateFileMD5(installDetails.GitLfsExecutablePath); var expectedGitLfsExecutableMd5 = environment.IsWindows ? GitInstallDetails.WindowsGitLfsExecutableMD5 : GitInstallDetails.MacGitLfsExecutableMD5; if (!expectedGitLfsExecutableMd5.Equals(gitLfsExecutableMd5, StringComparison.InvariantCultureIgnoreCase)) { Logger.Warning($"Path {installDetails.GitLfsExecutablePath} has MD5 {gitLfsExecutableMd5} expected {expectedGitLfsExecutableMd5}"); return(false); } Logger.Trace("Git Present"); return(true); }
/// <summary> /// Reports if this <see cref="ReleaseEntry"/> is valid and can be applied /// </summary> /// <param name="applicationVersion">What is the application version is</param> /// <param name="checkFile">If we should also check the update file and not just the metadata we have about it and if it's currently on disk</param> public virtual bool IsValidReleaseEntry(SemanticVersion applicationVersion, bool checkFile = false) { //If we want to check the file then we want to check the SHA256 + file size if (checkFile) { //Check that file exists if (!File.Exists(FileLocation)) { _logger.Warning("{0} doesn't exist, this release entry isn't valid", FileLocation); return(false); } var file = StreamUtil.SafeOpenRead(FileLocation); if (file?.Length != Filesize || !SHA256Util.CheckSHA256(file, SHA256)) { file?.Dispose(); _logger.Warning("{0} validation failed, this release entry isn't valid", FileLocation); return(false); } file.Dispose(); } //Check that this Version is higher then what we are running now return(applicationVersion < Version); }
public async Task Login(string username, string password, Action <LoginResult> need2faCode, Action <bool, string> result) { Guard.ArgumentNotNull(need2faCode, "need2faCode"); Guard.ArgumentNotNull(result, "result"); LoginResultData res = null; try { res = await loginManager.Login(OriginalUrl, username, password); } catch (Exception ex) { logger.Warning(ex); result(false, ex.Message); return; } if (res.Code == LoginResultCodes.CodeRequired) { var resultCache = new LoginResult(res, result, need2faCode); need2faCode(resultCache); } else { result(res.Code == LoginResultCodes.Success, res.Message); } }
public async Task <IKeychainAdapter> Load(UriString host) { KeychainAdapter keychainAdapter = FindOrCreateAdapter(host); var cachedConnection = connectionCache[host]; logger.Trace($@"Loading KeychainAdapter Host:""{host}"" Cached Username:""{cachedConnection.Username}"""); var keychainItem = await credentialManager.Load(host); if (keychainItem == null) { logger.Warning("Cannot load host from Credential Manager; removing from cache"); await Clear(host, false); } else { if (keychainItem.Username != cachedConnection.Username) { logger.Warning("Keychain Username: {0} does not match; Hopefully it works", keychainItem.Username); } logger.Trace("Loaded from Credential Manager Host:\"{0}\" Username:\"{1}\"", keychainItem.Host, keychainItem.Username); keychainAdapter.Set(keychainItem); } return(keychainAdapter); }
public bool LoginWithToken(UriString host, string token) { Guard.ArgumentNotNull(host, nameof(host)); Guard.ArgumentNotNullOrWhiteSpace(token, nameof(token)); var keychainAdapter = keychain.Connect(host); keychainAdapter.Set(new Credential(host, "[token]", token)); try { var username = RetrieveUsername(token, host); keychainAdapter.Update(token, username); keychain.SaveToSystem(host); return(true); } catch (Exception e) { logger.Warning(e, "Login Exception"); keychain.Clear(host, false); return(false); } }
public void AddRoom(ProceduralRoom room) { if (m_rooms.ContainsKey(room.RoomID)) { throw new ArgumentException("Room ID already used"); } m_rooms[room.RoomID] = room; var aabb = room.BoundingBoxBoth; room.m_aabbProxyID = m_roomTree.AddProxy(ref aabb, room, 0); m_roomsSafeOrder.Add(room); foreach (var k in room.MountPoints) { foreach (var p in k.MountLocations) { if (m_mountPoints.ContainsKey(p)) { Logger.Warning("Room {0} at {1} has mount point {4}:{5} that intersect with mount point {6}:{7} of room {2} at {3}", m_mountPoints[p].Owner.Part.Name, m_mountPoints[p].Owner.Transform.Translation, room.Part.Name, room.Transform.Translation, m_mountPoints[p].MountPoint.MountType, m_mountPoints[p].MountPoint.MountName, k.MountPoint.MountType, k.MountPoint.MountName); } else { m_mountPoints.Add(p, k); } } } room.TakeOwnership(this); using (room.Part.LockSharedUsing()) BlockSetInfo.AddToSelf(room.Part.BlockSetInfo); RoomAdded?.Invoke(room); }
/// <inheritdoc/> public async Task <LoginResultData> Login( UriString host, string username, string password) { Guard.ArgumentNotNull(host, nameof(host)); Guard.ArgumentNotNullOrWhiteSpace(username, nameof(username)); Guard.ArgumentNotNullOrWhiteSpace(password, nameof(password)); // Start by saving the username and password, these will be used by the `IGitHubClient` // until an authorization token has been created and acquired: keychain.Connect(host); keychain.SetCredentials(new Credential(host, username, password)); try { var loginResultData = await TryLogin(host, username, password); if (loginResultData.Code == LoginResultCodes.Success || loginResultData.Code == LoginResultCodes.CodeRequired) { if (string.IsNullOrEmpty(loginResultData.Token)) { throw new InvalidOperationException("Returned token is null or empty"); } if (loginResultData.Code == LoginResultCodes.Success) { username = await RetrieveUsername(loginResultData, username); } keychain.SetToken(host, loginResultData.Token, username); if (loginResultData.Code == LoginResultCodes.Success) { await keychain.Save(host); } return(loginResultData); } return(loginResultData); } catch (Exception e) { logger.Warning(e, "Login Exception"); await keychain.Clear(host, false); return(new LoginResultData(LoginResultCodes.Failed, Localization.LoginFailed, host)); } }
private async Task SendUsage() { var usageStore = usageLoader.Load(userId); if (metricsService == null) { Logger.Warning("No service, not sending usage"); return; } if (usageStore.LastUpdated.Date != DateTimeOffset.UtcNow.Date) { var currentTimeOffset = DateTimeOffset.UtcNow; var beforeDate = currentTimeOffset.Date; var success = false; var extractReports = usageStore.Model.SelectReports(beforeDate); if (!extractReports.Any()) { Logger.Trace("No items to send"); } else { if (!Enabled) { Logger.Trace("Metrics disabled"); return; } try { await metricsService.PostUsage(extractReports); success = true; } catch (Exception ex) { Logger.Warning(@"Error Sending Usage Exception Type:""{0}"" Message:""{1}""", ex.GetType().ToString(), ex.GetExceptionMessageShort()); } } if (success) { usageStore.Model.RemoveReports(beforeDate); usageStore.LastUpdated = currentTimeOffset; usageLoader.Save(usageStore); } } }
private async Task SetupGit() { Logger.Trace("Run - CurrentDirectory {0}", NPath.CurrentDirectory); if (Environment.GitExecutablePath == null) { Environment.GitExecutablePath = await DetermineGitExecutablePath(); Logger.Trace("Environment.GitExecutablePath \"{0}\" Exists:{1}", Environment.GitExecutablePath, Environment.GitExecutablePath.FileExists()); if (Environment.IsWindows) { var credentialHelper = await GitClient.GetConfig("credential.helper", GitConfigSource.Global).StartAwait(); if (!string.IsNullOrEmpty(credentialHelper)) { Logger.Trace("Windows CredentialHelper: {0}", credentialHelper); } else { Logger.Warning("No Windows CredentialHeloper found: Setting to wincred"); await GitClient.SetConfig("credential.helper", "wincred", GitConfigSource.Global).StartAwait(); } } } }
public static void Copy(SPath fromPath, SPath toPath) { Logger.Trace("Copying from {0} to {1}", fromPath, toPath); try { CopyFolder(fromPath, toPath); } catch (Exception ex1) { Logger.Warning(ex1, "Error copying."); try { CopyFolderContents(fromPath, toPath); } catch (Exception ex2) { Logger.Error(ex2, "Error copying contents."); throw; } } finally { fromPath.DeleteIfExists(); } }
/// <summary> /// Creates a <see cref="ReleaseEntry"/> from <see cref="ReleaseFile"/>'s /// </summary> /// <param name="releaseFiles">Release files</param> /// <param name="folderLocation">Where the release will be located</param> /// <param name="tag">Tag to use for any extra data (Normally the tag that is linked to a <see cref="ReleaseFile"/> in services)</param> public static IEnumerable <ReleaseEntry> ToReleaseEntries( this IEnumerable <ReleaseFile> releaseFiles, string folderLocation, object?tag = null) { foreach (var releaseFile in releaseFiles) { var fileName = Path.GetFileNameWithoutExtension(releaseFile.Name); var version = fileName.ToVersion(); if (version == null) { Logger.Warning("We can't grab the version that {0} is from the filename, skipping...", fileName); continue; } yield return(new ReleaseEntry( releaseFile.SHA256, releaseFile.Name, releaseFile.Size, VersionExt.OsRegex.Replace(fileName, string.Empty).EndsWith("-delta"), version, folderLocation, releaseFile.OldVersion, tag, releaseFile.StagingPercentage)); } }
/// <summary> /// Creates a RELEASE file /// </summary> /// <param name="releaseFiles">All the release data to put into the RELEASE file</param> /// <param name="fileLocation">Where the file should be located (Do not give a filename, we add that ourselves)</param> /// <returns>If we was able to create a RELEASE file</returns> public static async Task <bool> CreateReleaseFile(IEnumerable <ReleaseFile> releaseFiles, string fileLocation) { if (!Directory.Exists(fileLocation)) { Logging.Error("Directory {0} doesn't exist, failing...", fileLocation); return(false); } fileLocation = Path.Combine(fileLocation, "RELEASE"); var file = new FileInfo(fileLocation); var oldReleases = Array.Empty <ReleaseFile>(); if (file.Exists) { Logging.Warning("{0} already exists, grabbing all valid releases and recreating file", fileLocation); oldReleases = ReadReleaseFile(File.ReadLines(fileLocation)).ToArray(); file.Delete(); } using var textFileStream = file.CreateText(); foreach (var releaseFile in releaseFiles.Concat(oldReleases)) { await textFileStream.WriteLineAsync(releaseFile.ToString()); } return(true); }
public static void Copy(NPath fromPath, NPath toPath) { try { CopyFolder(fromPath, toPath); } catch (Exception ex1) { Logger.Warning(ex1, "Error copying from " + fromPath + " to " + toPath + ". Attempting to copy contents."); try { CopyFolderContents(fromPath, toPath); } catch (Exception ex2) { Logger.Error(ex2, "Error copying from " + fromPath + " to " + toPath + "."); throw; } } finally { fromPath.DeleteIfExists(); } }
public override async Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken) { long amountToWrite = -1; if (CanSeek && destination.CanSeek) { amountToWrite = _innerStream.Length - _innerStream.Position; } if (amountToWrite == -1) { _logger.Warning("We can't give a report for CopyToAsync due to one of the streams not supporting Seeking"); await _innerStream.CopyToAsync(destination, bufferSize, cancellationToken); return; } var buf = new byte[bufferSize]; for (int i = 0; i < amountToWrite; i += bufferSize) { var readCount = await _innerStream.ReadAsync(buf, 0, bufferSize, cancellationToken); await destination.WriteAsync(buf, 0, readCount, cancellationToken); _readAction?.Invoke(readCount); } }
private bool InvalidationFailed(Exception ex, CacheType cacheType) { Logger.Warning(ex, "Error invalidating {0}", cacheType); var managedCache = cacheContainer.GetCache(cacheType); managedCache.ResetInvalidation(); return(false); }
public void Run(bool firstRun) { Logger.Trace("Run - CurrentDirectory {0}", NPath.CurrentDirectory); var octorunScriptPath = Environment.UserCachePath.Combine("octorun", "src", "bin", "app.js"); Logger.Trace("Using octorunScriptPath: {0}", octorunScriptPath); var gitExecutablePath = SystemSettings.Get(Constants.GitInstallPathKey)?.ToNPath(); if (gitExecutablePath.HasValue && gitExecutablePath.Value.FileExists()) // we have a git path { Logger.Trace("Using git install path from settings: {0}", gitExecutablePath); InitializeEnvironment(gitExecutablePath.Value, octorunScriptPath); } else // we need to go find git { Logger.Trace("No git path found in settings"); var initEnvironmentTask = new ActionTask <NPath>(CancellationToken, (_, path) => InitializeEnvironment(path, octorunScriptPath)) { Affinity = TaskAffinity.UI }; var findExecTask = new FindExecTask("git", CancellationToken) .FinallyInUI((b, ex, path) => { if (b && path.IsInitialized) { Logger.Trace("FindExecTask Success: {0}", path); InitializeEnvironment(path, octorunScriptPath); } else { Logger.Warning("FindExecTask Failure"); Logger.Error("Git not found"); } }); var installDetails = new GitInstallDetails(Environment.UserCachePath, true); var gitInstaller = new GitInstaller(Environment, CancellationToken, installDetails); // if successful, continue with environment initialization, otherwise try to find an existing git installation gitInstaller.SetupGitIfNeeded(initEnvironmentTask, findExecTask); } }
//When building from source //--------------------------- //main.cpp: Change {APPLICATIONLOCATION} with location //If icon exists: add 'IDI_ICON1 ICON DISCARDABLE "app.ico"' to app.rc //When building from pre-built binary //------------------------------------- //Change {APPLICATIONLOCATION} in binary to path that the application will be //Inject icon into binary /// <summary> /// Creates the loader that will be needed for loading the application /// </summary> /// <param name="tmpFolder">Where the temp folder is</param> /// <param name="path">The relative path to the application</param> /// <param name="iconLocation">Where the icon is for this application</param> /// <param name="outputFile">Where to put the loader</param> /// <param name="applicationName">The application name</param> /// <param name="intendedOs">What OS this loader is intended for</param> /// <returns>If the loader was created</returns> public static LoadCreateStatus CreateLoader(TemporaryFolder tmpFolder, string path, string?iconLocation, string outputFile, string applicationName, OSPlatform?intendedOs) { if (File.Exists(outputFile)) { Logger.Warning("Loader file already exists in output. Deleting old loader"); File.Delete(outputFile); } path = path.Replace(@"\", @"\\"); var prebuiltStatus = LoaderCreatorPrebuilt.CreateLoader(path, iconLocation, outputFile, intendedOs); if (prebuiltStatus == LoadCreateStatus.Successful) { return(LoadCreateStatus.Successful); } Logger.Warning("Unable to use prebuilt loader! (Status: {0})", Enum.GetName(typeof(LoadCreateStatus), prebuiltStatus)); return(LoaderCreatorSource.CreateLoader(tmpFolder, path, iconLocation, outputFile, applicationName)); }
public void LoginWithToken(string token, Action <bool> result) { Guard.ArgumentNotNull(token, "token"); Guard.ArgumentNotNull(result, "result"); new FuncTask <bool>(taskManager.Token, () => loginManager.LoginWithToken(HostAddress.WebUri.Host, token)) .FinallyInUI((success, ex, res) => { if (!success) { logger.Warning(ex); result(false); return; } result(res); }) .Start(); }
/// <summary> /// Provides a <see cref="FileStream"/> after doing some checking /// </summary> /// <param name="fileLocation">File to grab</param> public static FileStream?SafeOpenRead(string fileLocation) { if (!File.Exists(fileLocation)) { Logger.Warning("{0} doesn't exist, can't open", fileLocation); return(null); } try { return(File.OpenRead(fileLocation)); } catch (Exception e) { Logger.Error(e); } Logger.Warning("Couldn't open {0}", fileLocation); return(null); }
private UsageStore LoadUsage() { UsageStore result = null; string json = null; if (storePath.FileExists()) { Logger.Trace("LoadUsage: \"{0}\"", storePath); try { json = storePath.ReadAllText(Encoding.UTF8); if (json != null) { result = SimpleJson.DeserializeObject <UsageStore>(json); } } catch (Exception ex) { Logger.Warning(ex, "Error Loading Usage: {0}; Deleting File", storePath); try { storePath.DeleteIfExists(); } catch {} } } if (result == null) { result = new UsageStore(); } if (String.IsNullOrEmpty(result.Model.Guid)) { result.Model.Guid = guid; } return(result); }
public void Run(bool firstRun) { Logger.Trace("Run - CurrentDirectory {0}", NPath.CurrentDirectory); var gitExecutablePath = SystemSettings.Get(Constants.GitInstallPathKey)?.ToNPath(); if (gitExecutablePath != null && gitExecutablePath.FileExists()) // we have a git path { Logger.Trace("Using git install path from settings: {0}", gitExecutablePath); InitializeEnvironment(gitExecutablePath); } else // we need to go find git { Logger.Trace("No git path found in settings"); var initEnvironmentTask = new ActionTask <NPath>(CancellationToken, (b, path) => InitializeEnvironment(path)) { Affinity = TaskAffinity.UI }; var findExecTask = new FindExecTask("git", CancellationToken) .FinallyInUI((b, ex, path) => { if (b && path != null) { Logger.Trace("FindExecTask Success: {0}", path); InitializeEnvironment(gitExecutablePath); } else { Logger.Warning("FindExecTask Failure"); Logger.Error("Git not found"); } }); var applicationDataPath = Environment.GetSpecialFolder(System.Environment.SpecialFolder.LocalApplicationData).ToNPath(); var installDetails = new GitInstallDetails(applicationDataPath, true); var gitInstaller = new GitInstaller(Environment, CancellationToken, installDetails); // if successful, continue with environment initialization, otherwise try to find an existing git installation gitInstaller.SetupGitIfNeeded(initEnvironmentTask, findExecTask); } }
protected async Task <HttpResponseMessage?> GetResponseMessage(HttpRequestMessage requestMessage) { if (_rateLimitTime != null) { if (_rateLimitTime > DateTime.Now) { Logger.Warning("We are still in the rate limit timeframe (Resets at {0}), not going to try this request", _rateLimitTime); return(null); } //Null it if we no-longer are in the rate limit timeframe _rateLimitTime = null; } var response = await HttpClient.GetResponseMessage(requestMessage); if (response == null) { return(null); } //Check that we got something from it if (response.IsSuccessStatusCode) { return(response); } var rateLimit = await GetRateLimitTime(response); if (rateLimit.IsRateLimited) { Logger.Error("We are being rate limited! This will reset at {0}", rateLimit.ResetTime !.Value); _rateLimitTime = rateLimit.ResetTime.Value; return(null); } //Report based on the status code as it might show what the user/api has done Logger.Error("Github returned an unsuccessful status code ({0})", response.StatusCode); switch (response.StatusCode) { case HttpStatusCode.Unauthorized: Logger.Error("We detected that the status code was 401; have you given a valid personal token? (You need the token to have public_repo)"); break; case HttpStatusCode.NotFound: Logger.Error("We detected that the status code was 404; did you misspell or not give a token for accessing a private repo?"); break; } return(null); }
public ProceduralGridComponent SpawnAsync() { var dirtyGrids = new HashSet <long>(); var allGrids = new List <IMyCubeGrid>(); // This ensures that dirtyGrids gets populated before the spawning callback runs. lock (dirtyGrids) { var iwatch = new Stopwatch(); iwatch.Restart(); PrimaryGrid.IsStatic = true; var primaryGrid = CreateFromObjectBuilderShim(PrimaryGrid, true, () => FlagIfReady(PrimaryGrid.EntityId, dirtyGrids, allGrids)) as IMyCubeGrid; if (primaryGrid == null) { Logger.Error("Failed to remap primary entity. Aborting spawn."); return(null); } dirtyGrids.Add(PrimaryGrid.EntityId); allGrids.Add(primaryGrid); Logger.Debug("Created entity for {0} room grid in {1}", Construction.Rooms.Count(), iwatch.Elapsed); if (Settings.AllowAuxillaryGrids) { iwatch.Restart(); foreach (var aux in AuxGrids) { // ReSharper disable once ImplicitlyCapturedClosure var res = CreateFromObjectBuilderShim(aux, true, () => FlagIfReady(aux.EntityId, dirtyGrids, allGrids)) as IMyCubeGrid; if (res == null) { Logger.Warning("Failed to remap secondary entity. Skipping."); continue; } allGrids.Add(res); dirtyGrids.Add(aux.EntityId); } if (AuxGrids.Count > 0) { Logger.Debug("Created {0} aux grids in {1}", AuxGrids.Count, iwatch.Elapsed); } } var component = new ProceduralGridComponent(Construction, allGrids); primaryGrid.Components.Add(component); return(component); } }
/// <summary> /// Initialize environment after finding where git is. This needs to run on the main thread /// </summary> /// <param name="gitExecutablePath"></param> /// <param name="octorunScriptPath"></param> private void InitializeEnvironment(GitInstaller.GitInstallationState installationState) { isBusy = false; SetupMetrics(); if (!installationState.GitIsValid) { return; } var gitInstallDetails = new GitInstaller.GitInstallDetails(Environment.UserCachePath, Environment.IsWindows); var isCustomGitExec = installationState.GitExecutablePath != gitInstallDetails.GitExecutablePath; Environment.GitExecutablePath = installationState.GitExecutablePath; Environment.GitLfsExecutablePath = installationState.GitLfsExecutablePath; Environment.IsCustomGitExecutable = isCustomGitExec; Environment.User.Initialize(GitClient); var afterGitSetup = new ActionTask(CancellationToken, RestartRepository) .ThenInUI(InitializeUI); ITask task = afterGitSetup; if (Environment.IsWindows) { var credHelperTask = GitClient.GetConfig("credential.helper", GitConfigSource.Global); credHelperTask.OnEnd += (thisTask, credentialHelper, success, exception) => { if (!success || string.IsNullOrEmpty(credentialHelper)) { Logger.Warning("No Windows CredentialHelper found: Setting to wincred"); thisTask .Then(GitClient.SetConfig("credential.helper", "wincred", GitConfigSource.Global)) .Then(afterGitSetup); } else { thisTask.Then(afterGitSetup); } }; task = credHelperTask; } task.Start(); }
public ApplicationMetadata() { //Get the assembly if possible and get data out of it var runningAssembly = Assembly.GetEntryAssembly(); if (runningAssembly == null) { _logging.Warning("Can't get running assembly, will not have any metadata to work with!"); return; } var applicationName = runningAssembly.GetName(); ApplicationVersion = runningAssembly.GetSemanticVersion() ?? SemanticVersion.BaseVersion(); ApplicationName = applicationName.Name !; var folder = runningAssembly.Location; folder = folder[..folder.LastIndexOf(Path.DirectorySeparatorChar)];
/// <summary> /// Processes a file that has a delta update /// </summary> /// <param name="tempFolder">Where the temp folder is located</param> /// <param name="originalFile">Where the original file is</param> /// <param name="newFile">Where the updated file should be placed on disk</param> /// <param name="file">Details about the update</param> /// <param name="progress">Progress for applying the update</param> /// <returns>If the file was successfully updated</returns> public static async Task <bool> ProcessDeltaFile(TemporaryFolder tempFolder, string originalFile, string newFile, FileEntry file, Action <double>?progress = null) { if (file.Stream == null) { Logger.Warning("{0} was updated but we don't have the delta stream for it!", file.Filename); return(false); } Logger.Debug("File was updated, applying delta update"); var deltaUpdater = DeltaUpdaters.GetUpdater(file.DeltaExtension); if (deltaUpdater != null) { return(await deltaUpdater.ApplyDeltaFile(tempFolder, originalFile, newFile, file.Filename, file.Stream, progress)); } Logger.Error("Wasn't able to find what was responsible for creating this diff file (File: {0}, Extension: {1})", file.Filename, file.DeltaExtension); return(false); }
public async Task <IKeychainAdapter> Load(UriString host) { var keychainAdapter = FindOrCreateAdapter(host); logger.Trace("Load KeychainAdapter Host:\"{0}\"", host); var keychainItem = await credentialManager.Load(host); if (keychainItem == null) { logger.Warning("Cannot load host from credential manager; removing from cache"); await Clear(host, false); } else { logger.Trace("Loading KeychainItem:{0}", keychainItem.ToString()); keychainAdapter.Set(keychainItem); } return(keychainAdapter); }