From f266b843ed6c9650ecaabb0d71b30a7646980897 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 2 Feb 2013 19:34:23 -0800 Subject: [PATCH] schema: simplify WriteFileChunks Change-Id: Icf9077db0adb5081b93f89ddc9d74a4cc45f20e1 --- pkg/schema/filewriter.go | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/pkg/schema/filewriter.go b/pkg/schema/filewriter.go index 39af442e8..87079872a 100644 --- a/pkg/schema/filewriter.go +++ b/pkg/schema/filewriter.go @@ -268,26 +268,19 @@ func writeFileMapRolling(bs blobserver.StatReceiver, file *Builder, r io.Reader) return uploadBytes(bs, file, n, spans) } -// WriteFileChunks uploads chunks of r to bs while populating fileMap. -// It does not upload fileMap. +// WriteFileChunks uploads chunks of r to bs while populating file. +// It does not upload file. func WriteFileChunks(bs blobserver.StatReceiver, file *Builder, r io.Reader) error { - rootFile := func() *Builder { return file } - - n, spans, err := writeFileChunks(bs, file, r) + size, spans, err := writeFileChunks(bs, file, r) if err != nil { return err } - topLevel := func(source func() *Builder, size int64, s []span) error { - parts := []BytesPart{} - err := addBytesParts(bs, &parts, s) - if err != nil { - return err - } - return source().PopulateParts(size, parts) + parts := []BytesPart{} + err = addBytesParts(bs, &parts, spans) + if err != nil { + return err } - - // The top-level content parts - return topLevel(rootFile, n, spans) + return file.PopulateParts(size, parts) } func writeFileChunks(bs blobserver.StatReceiver, file *Builder, r io.Reader) (n int64, spans []span, outerr error) {