From 05ac09bf697986e1dec495341930eabd5d29c4fe Mon Sep 17 00:00:00 2001 From: "Frederick F. Kautz IV" Date: Wed, 18 Feb 2015 10:18:24 -0800 Subject: [PATCH] Adding header version --- pkg/storage/donut/donut.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/pkg/storage/donut/donut.go b/pkg/storage/donut/donut.go index c45b17251..1d6414eb5 100644 --- a/pkg/storage/donut/donut.go +++ b/pkg/storage/donut/donut.go @@ -39,16 +39,26 @@ func (donut Donut) Write(header Header, object io.Reader) error { return err } - // write header length - var headerLengthBuffer bytes.Buffer - headerLength := headerBuffer.Len() - err = binary.Write(&headerLengthBuffer, binary.LittleEndian, headerLength) + // prefix consists of a version number and a length + var headerPrefixBuffer bytes.Buffer + // write version + var version int + version = 1 + err = binary.Write(&headerPrefixBuffer, binary.LittleEndian, version) if err != nil { return err } - // write header length - io.Copy(&newObjectBuffer, &headerLengthBuffer) + // write length + var headerLength int + headerLength = headerBuffer.Len() + err = binary.Write(&headerPrefixBuffer, binary.LittleEndian, headerLength) + if err != nil { + return err + } + + // write header prefix + io.Copy(&newObjectBuffer, &headerPrefixBuffer) // write header io.Copy(&newObjectBuffer, &headerBuffer)