snap: call fsync before close db file

release-2.3
Xiang Li 2015-12-22 22:43:05 -08:00
parent 289de69632
commit 191c5ef9cb
1 changed files with 3 additions and 0 deletions

View File

@ -32,6 +32,9 @@ func (s *Snapshotter) SaveDBFrom(r io.Reader, id uint64) error {
return err
}
_, err = io.Copy(f, r)
if err == nil {
err = f.Sync()
}
f.Close()
if err != nil {
os.Remove(f.Name())