private void ProcessFileEntry(FileEntry fileEntry) { //Get rid of any streams that will be empty if (fileEntry.Filesize == 0) { fileEntry.Stream?.Dispose(); fileEntry.Stream = null; } //Add to the correct if (fileEntry.IsDeltaFile()) { DeltaFile.Add(fileEntry); return; } if (fileEntry.IsNewFile()) { NewFile.Add(fileEntry); return; } if (fileEntry.DeltaExtension.EndsWith("load")) { LoaderFile = fileEntry; return; } SameFile.Add(fileEntry); }
public void LoadXMLInformation_XmlWithCategory() { FileInfo file = new FileInfo(@"..\..\TestFiles\DeltaXML\DeltaHasXmlWithCategory.sql"); DeltaFile deltaFile = new DeltaFile(); deltaFile.LoadXMLInformation(file); Assert.AreEqual("ThisIsATest", deltaFile.Category); Assert.AreEqual(false, deltaFile.UseTransaction); Assert.AreEqual(0, deltaFile.MaySkipCategories.Count); }
public void LoadXMLInformation_XmlButNoChildNodes() { FileInfo file = new FileInfo(@"..\..\TestFiles\DeltaXML\DeltaHasXmlButNoChildNodes.sql"); DeltaFile deltaFile = new DeltaFile(); deltaFile.LoadXMLInformation(file); Assert.AreEqual(null, deltaFile.Category); Assert.AreEqual(false, deltaFile.UseTransaction); Assert.AreEqual(0, deltaFile.MaySkipCategories.Count); }
/// <summary> /// Generates a delta stream /// </summary> /// <param name="signature">The signature for the stream</param> /// <param name="filename">The (possibly) altered stream to create the delta for</param> /// <param name="output">The delta output</param> public static void GenerateDelta(Stream signature, Stream input, Stream output) { ChecksumFileReader checksum; //Write header into output file output.Write(RDiffBinary.DELTA_MAGIC, 0, RDiffBinary.DELTA_MAGIC.Length); checksum = new ChecksumFileReader(signature); DeltaFile.GenerateDeltaFile(input, output, checksum); }
public void LoadXMLInformation_FullXmll() { FileInfo file = new FileInfo(@"..\..\TestFiles\DeltaXML\DeltaHasFullXml.sql"); DeltaFile deltaFile = new DeltaFile(); deltaFile.LoadXMLInformation(file); Assert.AreEqual("ThisIsATest", deltaFile.Category); Assert.AreEqual(true, deltaFile.UseTransaction); Assert.AreEqual(3, deltaFile.MaySkipCategories.Count); Assert.AreEqual("z", deltaFile.MaySkipCategories[2]); }
/// <summary> /// Loads everything from a <see cref="IAsyncEnumerable{T}"/> into this <see cref="UpdateEntry"/> /// </summary> /// <param name="fileEntries">File entries to load in</param> public async Task LoadAsyncEnumerable(IAsyncEnumerable <FileEntry?> fileEntries) { await foreach (var fileEntry in fileEntries) { /*If the fileEntry is null then something happened while grabbing* * the update files, clear out*/ if (fileEntry == null) { DeltaFile.Clear(); SameFile.Clear(); NewFile.Clear(); break; } ProcessFileEntry(fileEntry); } }
/// <summary> /// Constructs a stream from a basestream and a delta stream /// </summary> /// <param name="basefile">The most recent full copy of the file</param> /// <param name="deltafile">The delta file</param> /// <param name="outputfile">The restored file</param> public static void PatchFile(Stream basestream, Stream delta, Stream output) { DeltaFile.PatchFile(basestream, output, delta); }