Пример #1
0
        private void CreateArchiveFile()
        {
            string archiveFileFullPath = Path.Combine(projectArchiveDirectoryFullPath, projectDirectoryName + fileCompressor.DefaultExtension);

            if (storage.ExistsFile(archiveFileFullPath))
            {
                throw new ProjArchiveException(Resources.Err_ArchiveAlreadyExists);
            }

            logger.Info("Creating compressed file: '{0}'.", archiveFileFullPath);

            fileCompressor.Compress(ProjectDirectoryFullPath, archiveFileFullPath);
        }
        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);
            }
        }
Пример #3
0
        private static void Work()
        {
            var creator = new FileCompressorCreator();

            using (IFileCompressor compressor = creator.Create())
            {
                CompressionParams @params = CompressionParams.Instance;
                if (@params.Compress)
                {
                    compressor.Compress(@params.InputFileName, @params.OutputFileName);
                }
                else
                {
                    compressor.Decompress(@params.InputFileName, @params.OutputFileName);
                }
            }
        }
Пример #4
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);
        }
Пример #5
0
        public void CompressorShouldWriteAsManyBlocksAsItRead()
        {
            /*компрессор должен записать столько же блоков сколько прочитал из источника
             */

            //init
            var byteBlocks = new byte[][]
            {
                new byte[] { 1, 2, 3, 54 },
                new byte[] { 2, 5, 8, 24 }
            };

            IFileCompressor compressor = null;
            //будем считать сколько блоков прошло через особую реализацию писателя
            var writer              = new WaitWriterWithCounting();
            var blocksSource        = new HardcodedBlocksSource(byteBlocks);
            var compressionStrategy = new NoCompressionStrategy();

            using (var cont = new UnityContainer())
            {
                cont.RegisterInstance <ICompressingSettings>(new SimpleCompressingSettings()
                {
                    MaximumThreadsToUse = 5
                });
                cont.RegisterInstance <IOutputWriter>(writer);
                cont.RegisterInstance <ILogger>(new Mock <ILogger>().Object);
                cont.RegisterInstance <IBlocksToCompressSource>(blocksSource);
                cont.RegisterInstance <ICompressionStrategy>(compressionStrategy);

                compressor = cont.Resolve <BlockCompressor>();
            }

            //act
            var res = compressor.Compress();

            //assert
            Assert.AreEqual(true, res);
            Assert.AreEqual(2, writer.BlocksReceived);
        }