public void CanFilterLargeFiles() { const int ContentLength = 128 * 1024 * 1024 - 13; const char ContentValue = 'x'; char[] content = (new string(ContentValue, 1024)).ToCharArray(); string repoPath = InitNewRepository(); var filter = new FileExportFilter(FilterName, attributes); var registration = GlobalSettings.RegisterFilter(filter); try { string filePath = Path.Combine(Directory.GetParent(repoPath).Parent.FullName, Guid.NewGuid().ToString() + ".blob"); FileInfo contentFile = new FileInfo(filePath); using (var writer = new StreamWriter(contentFile.OpenWrite()) { AutoFlush = true }) { int remain = ContentLength; while (remain > 0) { int chunkSize = remain > content.Length ? content.Length : remain; writer.Write(content, 0, chunkSize); remain -= chunkSize; } } string attributesPath = Path.Combine(Directory.GetParent(repoPath).Parent.FullName, ".gitattributes"); FileInfo attributesFile = new FileInfo(attributesPath); string configPath = CreateConfigurationWithDummyUser(Constants.Identity); var repositoryOptions = new RepositoryOptions { GlobalConfigurationLocation = configPath }; using (Repository repo = new Repository(repoPath, repositoryOptions)) { File.WriteAllText(attributesPath, "*.blob filter=test"); repo.Stage(attributesFile.Name); repo.Stage(contentFile.Name); repo.Commit("test", Constants.Signature, Constants.Signature); contentFile.Delete(); repo.Checkout("HEAD", new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force }); } contentFile = new FileInfo(filePath); Assert.True(contentFile.Exists, "Contents not restored correctly by forced checkout."); using (StreamReader reader = contentFile.OpenText()) { int totalRead = 0; char[] block = new char[1024]; int read; while ((read = reader.Read(block, 0, block.Length)) > 0) { Assert.True(CharArrayAreEqual(block, content, read)); totalRead += read; } Assert.Equal(ContentLength, totalRead); } contentFile.Delete(); } finally { GlobalSettings.DeregisterFilter(registration); } }
private void ButtonAnalyzeDataStream_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.Title = "Select IOC-Talk Data Stream File"; openFile.CheckFileExists = true; openFile.CheckPathExists = true; openFile.DefaultExt = ".dlog"; openFile.Filter = "IOC-Talk Data Stream Logs (.dlog)|*.dlog"; var result = openFile.ShowDialog(); if (result.HasValue && result.Value) { this.TabMainControl.IsEnabled = false; this.IsEnabled = false; this.DataContext = null; TimeSpan?roundTripTimeFilter = null; if (FilterTime) { roundTripTimeFilter = TimeSpan.Parse(TextBlockMinRoundTripTime.Text); } int?flowRateFilter = null; if (FilterFlowRate) { flowRateFilter = int.Parse(TextBloxMinFlowRateCount.Text); } string fileName = openFile.FileName; //// export test code FileExportFilter fileExport = null; //FileExportFilter fileExport = new FileExportFilter //{ // MessageNames = new string[] { "Post(x)" }, // ExportDirectory = $".{System.IO.Path.DirectorySeparatorChar}FileExportFilter", // //GroupByKeys = new string[] { "Context", "DevId", "Protocol" }, // GroupByKeys = new string[] { "DevId", "Protocol" }, // IncludeResponse = true, // Conditions = new FilterItem[] // { // new FilterItem // { // Key ="Context", // Value = "x" // } // }, // SeparateOnKey = "Message", // SeparateOnKeyValue = "", // ExportOnlyKey = "Message", // ExportWithSpaceSequence = 2 //}; ShowPleaseWait(); Task.Factory.StartNew(() => { try { StringBuilder sbErrors; streamSessions = analyzer.AnalyzeDataStreamSession(fileName, roundTripTimeFilter, flowRateFilter, OnProgressUpdate, fileExport, out sbErrors); ShowResults(streamSessions, sbErrors); } catch (Exception ex) { ShowError(ex.ToString()); } }); } }