public string AddSymbolFile(Symbol symbol, string file) { var destination = GetSymbolFilePath(symbol); var directory = Path.GetDirectoryName(destination); Directory.CreateDirectory(directory); File.Copy(file, destination); return destination; }
public ActionResult GetFile([FromRoute] string guid, [FromRoute] string module) { if (guid == null || module == null) { return new HttpStatusCodeResult(402); } var symbol = new Symbol() { SymbolId = guid, Module = module, }; var filePath = FileSystem.GetSymbolFile(symbol); if (filePath == null) { return HttpNotFound(); } return new PhysicalFileResult(filePath, "application/octet-stream"); }
public string GetSymbolFile(Symbol symbol) { var path = GetSymbolFilePath(symbol); if (File.Exists(path)) { return path; } else { return null; } }
public string GetSymbolFilePath(Symbol symbol) { return Path.Combine(SymbolsRoot, symbol.Module, symbol.SymbolId, symbol.Module); }
public IActionResult UploadPackage() { var files = Request.Form.Files; if (files.Count != 1) { return new BadRequestObjectResult(new { message = "Exactly one file should be uploaded at a time." }); } var file = files[0]; ContentDispositionHeaderValue contentDisposition; if (!ContentDispositionHeaderValue.TryParse(file.ContentDisposition, out contentDisposition)) { return new BadRequestObjectResult(new { message = "Bad Content-Disposition." }); } var packageFile = HeaderUtilities.RemoveQuotes(contentDisposition.FileName); var destination = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); using (var package = SymbolPackage.Extract(file.OpenReadStream(), packageFile, destination)) { foreach (var pdb in package.GetSymbols()) { var symbolId = SymbolReader.GetSymbolId(pdb); var symbol = new Symbol() { SymbolId = symbolId.ToString(), Module = Path.GetFileName(pdb) }; if (FileSystem.GetSymbolFile(symbol) == null) { FileSystem.AddSymbolFile(symbol, pdb); var originalSources = SymbolReader.GetOriginalSources(pdb); var packageSources = package.GetRelativeSources().ToArray(); if (packageSources.Length == 0 || originalSources.Count == 0) { // The package might now have sources, or the symbol might now have sources (assembly neutral interfaces). continue; } string prefix = null; foreach (var source in package.GetRelativeSources()) { var fullSourcePaths = originalSources.Where(s => s.EndsWith(source, StringComparison.OrdinalIgnoreCase)).ToArray(); if (fullSourcePaths.Length == 1) { // + 1 to include the a slash prefix = fullSourcePaths[0].Substring(0, fullSourcePaths[0].Length - source.Length + 1); break; } } if (prefix == null) { throw new Exception("Couldn't find a prefix bro"); } var stream = new SrcSrvStream() { Version = 1, VersionControl = "http", Target = "http://" + HttpContext.Request.Host + "/sources/" + package.PackageId + "/%var2%", }; // Currently our symbols for .cshtml files don't include the full path :( // We can't index those foreach (var source in originalSources) { if (source.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) { stream.Files.Add(source + "*" + source.Substring(prefix.Length).Replace('\\', '/')); } else { stream.Files.Add(source); } } SymbolReader.WriteStream(FileSystem.GetSymbolFilePath(symbol), stream.ToString()); } } var sourceDestination = FileSystem.GetSourceRootFilePath(package.PackageId); if (!Directory.Exists(sourceDestination)) { FileSystem.AddSources(package.PackageId, package.SourcesPath); } } return new HttpStatusCodeResult(200); }