private PooledMemoryStream ReadDataNoCaching(Stream log, long pos, int size, RavenJToken key) { log.Position = pos; var data = PooledMemoryStream.From(log, size); if (data.Length != size) { throw new InvalidDataException("Could not read complete data, the file is probably corrupt when reading: " + key.ToString(Formatting.None) + " on table " + Name); } var hash = data.ComputeHash(); var binaryReader = new BinaryReader(log); var hashFromFile = binaryReader.ReadBytes(hash.Length); if (hashFromFile.Length != hash.Length) { throw new InvalidDataException("Could not read complete SHA data, the file is probably corrupt when reading: " + key.ToString(Formatting.None) + " on table " + Name); } if (hashFromFile.Where((t, i) => hash[i] != t).Any()) { throw new InvalidDataException("Invalid SHA signature, the file is probably corrupt when reading: " + key.ToString(Formatting.None) + " on table " + Name); } return(data); }