add buffered snapshot writer

This commit wraps the snapshot in a `bufio.Writer`.
This commit is contained in:
Ben Johnson 2016-06-09 14:25:41 -06:00
parent 882d105e99
commit 64c29d4b6e
No known key found for this signature in database
GPG key ID: 780E98C6BEDA0915

View file

@ -2,6 +2,7 @@ package pilosa
import (
"archive/tar"
"bufio"
"bytes"
"crypto/sha1"
"encoding/binary"
@ -906,8 +907,11 @@ func (f *Fragment) snapshot() error {
defer file.Close()
// Write storage to snapshot.
if _, err := f.storage.WriteTo(file); err != nil {
bw := bufio.NewWriter(file)
if _, err := f.storage.WriteTo(bw); err != nil {
return fmt.Errorf("snapshot write to: %s", err)
} else if err := bw.Flush(); err != nil {
return fmt.Errorf("flush: %s", err)
}
// Close current storage.