private void ReadOctoDeltaHeader() { var version = reader.ReadByte(); if (version != OctoBinaryFormat.Version) { throw new InvalidDataException("The delta file uses a newer file format than this program can handle."); } var hashAlgorithmName = reader.ReadString(); hashAlgorithm = SupportedAlgorithms.Hashing.Create(hashAlgorithmName); var hashLength = reader.ReadInt32(); expectedHash = reader.ReadBytes(hashLength); var endOfMeta = reader.ReadBytes(OctoBinaryFormat.EndOfMetadata.Length); if (!StructuralComparisons.StructuralEqualityComparer.Equals(OctoBinaryFormat.EndOfMetadata, endOfMeta)) { throw new InvalidDataException("The delta file appears to be corrupt."); } _metadata = new DeltaMetadataLegacy { HashAlgorithm = hashAlgorithmName, ExpectedFileHashAlgorithm = hashAlgorithmName, ExpectedFileHash = Convert.ToBase64String(expectedHash) }; Type = RsyncFormatType.Octodiff; }
private void ReadFastRsyncDeltaHeader() { var version = reader.ReadByte(); if (version != FastRsyncBinaryFormat.Version) { throw new InvalidDataException("The delta file uses a newer file format than this program can handle."); } var metadataStr = reader.ReadString(); _metadata = JsonConvert.DeserializeObject <DeltaMetadataLegacy>(metadataStr, JsonSerializationSettings.JsonSettings); hashAlgorithm = SupportedAlgorithms.Hashing.Create(_metadata.HashAlgorithm); expectedHash = Convert.FromBase64String(_metadata.ExpectedFileHash); Type = RsyncFormatType.FastRsync; }