schema: simplify WriteFileChunks

Change-Id: Icf9077db0adb5081b93f89ddc9d74a4cc45f20e1
This commit is contained in:
Brad Fitzpatrick 2013-02-02 19:34:23 -08:00
parent 40209ae45e
commit f266b843ed
1 changed files with 8 additions and 15 deletions

View File

@ -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) {