Explorar el Código

snap: call fsync before close db file

Xiang Li hace 10 años
padre
commit
191c5ef9cb
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  1. 3 0
      snap/db.go

+ 3 - 0
snap/db.go

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