whoops, was using offset wrong in filewriter

This commit is contained in:
Brad Fitzpatrick 2011-05-30 19:24:19 -07:00
parent 2116273f64
commit 2c66ab38ad
1 changed files with 2 additions and 4 deletions

View File

@ -38,13 +38,11 @@ func WriteFileFromReader(bs blobserver.Storage, filename string, r io.Reader) (*
// Naive for now. Just in 1MB chunks. // Naive for now. Just in 1MB chunks.
// TODO: rolling hash and hash trees. // TODO: rolling hash and hash trees.
parts := []ContentPart{} parts, size := []ContentPart{}, int64(0)
size, offset := int64(0), int64(0)
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
for { for {
buf.Reset() buf.Reset()
offset = size
n, err := io.Copy(buf, io.LimitReader(r, 1<<20)) n, err := io.Copy(buf, io.LimitReader(r, 1<<20))
if err != nil { if err != nil {
@ -76,7 +74,7 @@ func WriteFileFromReader(bs blobserver.Storage, filename string, r io.Reader) (*
BlobRefString: br.String(), BlobRefString: br.String(),
BlobRef: br, BlobRef: br,
Size: uint64(n), Size: uint64(n),
Offset: uint64(offset), Offset: 0, // into BlobRef to read from (not of dest)
}) })
} }