public void WriteVariablesToDiskCache(GitVersionCacheKey cacheKey, VersionVariables variablesFromCache) { var cacheDir = PrepareCacheDirectory(); var cacheFileName = GetCacheFileName(cacheKey, cacheDir); variablesFromCache.FileName = cacheFileName; Dictionary <string, string> dictionary; using (log.IndentLog("Creating dictionary")) { dictionary = variablesFromCache.ToDictionary(x => x.Key, x => x.Value); } void WriteCacheOperation() { using var stream = fileSystem.OpenWrite(cacheFileName); using var sw = new StreamWriter(stream); using (log.IndentLog("Storing version variables to cache file " + cacheFileName)) { var serializer = new Serializer(); serializer.Serialize(sw, dictionary); } } var retryOperation = new OperationWithExponentialBackoff <IOException>(new ThreadSleep(), log, WriteCacheOperation, maxRetries: 6); retryOperation.ExecuteAsync().Wait(); }
public void WriteVariablesToDiskCache(GitVersionCacheKey cacheKey, VersionVariables variablesFromCache) { var cacheDir = PrepareCacheDirectory(); var cacheFileName = GetCacheFileName(cacheKey, cacheDir); variablesFromCache.FileName = cacheFileName; Dictionary <string, string> dictionary; using (this.log.IndentLog("Creating dictionary")) { dictionary = variablesFromCache.ToDictionary(x => x.Key, x => x.Value); } void WriteCacheOperation() { using var stream = this.fileSystem.OpenWrite(cacheFileName); using var sw = new StreamWriter(stream); using (this.log.IndentLog("Storing version variables to cache file " + cacheFileName)) { var serializer = new Serializer(); serializer.Serialize(sw, dictionary); } } var retryOperation = new RetryAction <IOException>(6); retryOperation.Execute(WriteCacheOperation); }
public void WriteVariablesToDiskCache(GitPreparer gitPreparer, GitVersionCacheKey cacheKey, VersionVariables variablesFromCache) { var cacheDir = PrepareCacheDirectory(gitPreparer); var cacheFileName = GetCacheFileName(cacheKey, cacheDir); variablesFromCache.FileName = cacheFileName; Dictionary<string, string> dictionary; using (Logger.IndentLog("Creating dictionary")) { dictionary = variablesFromCache.ToDictionary(x => x.Key, x => x.Value); } Action writeCacheOperation = () => { using (var stream = fileSystem.OpenWrite(cacheFileName)) { using (var sw = new StreamWriter(stream)) { using (Logger.IndentLog("Storing version variables to cache file " + cacheFileName)) { var serializer = new Serializer(); serializer.Serialize(sw, dictionary); } } } }; var retryOperation = new OperationWithExponentialBackoff<IOException>(new ThreadSleep(), writeCacheOperation, maxRetries: 6); retryOperation.Execute(); }
public void WriteVariablesToDiskCache(IRepository repo, string gitDir, VersionVariables variablesFromCache) { var cacheFileName = GetCacheFileName(GetKey(repo, gitDir), GetCacheDir(gitDir)); variablesFromCache.FileName = cacheFileName; using (var stream = fileSystem.OpenWrite(cacheFileName)) { using (var sw = new StreamWriter(stream)) { Dictionary<string, string> dictionary; using (Logger.IndentLog("Creating dictionary")) { dictionary = variablesFromCache.ToDictionary(x => x.Key, x => x.Value); } using (Logger.IndentLog("Storing version variables to cache file " + cacheFileName)) { var serializer = new Serializer(); serializer.Serialize(sw, dictionary); } } } }