private ActionResult PdbFile(IWinDbgBackend backend, ImageFile imageFile, string sourcePath)
        {
            var directoryPathTemp = Path.Combine(Path.GetTempPath(), "hss-temp-" + Path.GetRandomFileName());

            Directory.CreateDirectory(directoryPathTemp);

            var link      = backend.GetSymbolFileLink(ref imageFile);
            var tempPath  = Path.Combine(directoryPathTemp, imageFile.Name + ".pdb");
            var temp2Path = Path.Combine(directoryPathTemp, imageFile.Name + ".pd_");

            try
            {
                DownloadFile(link, tempPath);

                var pdbstr = new PdbSrcSrvSection();

                pdbstr.Ini.Add("VERSION", "2");
                pdbstr.Ini.Add("INDEXVERSION", "2");
                //TODO: jaka jest idea tych podmian, zamiast od razu wkleić %cośtam%?
                pdbstr.Variables.Add("SRCSRVTRG", sourcePath.Replace("XVAR2X", "%var2%").Replace("XCNX", "%CN%").Replace("XUNX", "%UN%"));
                pdbstr.Variables.Add("SRCSRVCMD", string.Empty);
                pdbstr.Variables.Add("UN", "%USERNAME%");
                pdbstr.Variables.Add("CN", "%COMPUTERNAME%");
                pdbstr.Variables.Add("SRCSRVVERCTRL", "http");
                pdbstr.Variables.Add("SRCSRVERRVAR", "var2");
                pdbstr.Ini.Add("VERCTRL", "http");

                var sources = backend.GetSourceFileList(ref imageFile);

                foreach (var source in sources)
                {
                    pdbstr.Sources.Add(new[] { source.OriginalPath, source.Path, source.Hash });
                }

                pdbStoreManager.WriteSrcSrv(tempPath, pdbstr);
                fileCompressor.Compress(tempPath, temp2Path);

                return(File(System.IO.File.ReadAllBytes(temp2Path), "application/octet-stream"));
            }
            finally
            {
                System.IO.File.Delete(tempPath);
                System.IO.File.Delete(temp2Path);
                Directory.Delete(directoryPathTemp);
            }
        }
Exemplo n.º 2
0
        private async Task <SymbolStatus> IndexSymbol(IStorageFeed feed, PackageName packageName, IBinaryInfo binaryInfo)
        {
            var symbolStatus = new SymbolStatus(new SymbolName(binaryInfo.Name, binaryInfo.SymbolInfo.Hash));

            try
            {
                Debug.WriteLine("Indexing symbol {0}", symbolStatus.SymbolName);
                await RequestOrSkip(string.Format("pdb/{0}", symbolStatus.SymbolName),
                                    async() =>
                {
                    Debug.WriteLine("Storing symbol {0}", symbolStatus.SymbolName);
                    var symbolItem = feed.GetSymbol(packageName, symbolStatus.SymbolName);

                    var pdbstrSection = CreatePdbStrSection(binaryInfo);
                    using (var inputStream = binaryInfo.SymbolInfo.File.GetStream())
                        using (var tempStream = new MemoryStream())
                            using (var outputStream = await symbolItem.Put())
                            {
                                pdbStoreManager.WriteSrcSrv(inputStream, tempStream, pdbstrSection);
                                tempStream.Position = 0;
                                var symbolFileName  = Path.GetFileName(binaryInfo.SymbolInfo.File.FullPath);
                                fileCompressor.Compress(symbolFileName, tempStream, outputStream);
                            }
                });

                symbolStatus.Stored = true;
                Debug.WriteLine("Stored symbol {0}", symbolStatus.SymbolName);
            }
            catch (Exception e)
            {
                support.TrackException(e, new { packageName });
                symbolStatus.Exception = new ExceptionStatus(e);
            }

            if (binaryInfo.SymbolInfo.SourceInfos != null)
            {
                symbolStatus.SourceStatuses = await ProcessThrottled(
                    5, binaryInfo.SymbolInfo.SourceInfos,
                    async s => await IndexSource(feed, packageName, s));
            }

            return(symbolStatus);
        }