Close() temp files before renaming them.

Fixes syncing dirty wallet files on Windows.
This commit is contained in:
Josh Rickmar 2013-10-23 18:40:02 -04:00
parent 9983a0a92a
commit 4b7f858bee

View file

@ -48,6 +48,7 @@ func (w *BtcWallet) writeDirtyToDisk() error {
if _, err = w.WriteTo(tmpfile); err != nil {
return err
}
tmpfile.Close()
// TODO(jrick): this should be atomic on *nix, but is not on
// Windows. Use _windows.go to provide atomic renames.
@ -70,6 +71,7 @@ func (w *BtcWallet) writeDirtyToDisk() error {
if _, err = w.TxStore.s.WriteTo(tmpfile); err != nil {
return err
}
tmpfile.Close()
// TODO(jrick): this should be atomic on *nix, but is not on
// Windows. Use _windows.go to provide atomic renames.
@ -92,6 +94,7 @@ func (w *BtcWallet) writeDirtyToDisk() error {
if _, err = w.UtxoStore.s.WriteTo(tmpfile); err != nil {
return err
}
tmpfile.Close()
// TODO(jrick): this should be atomic on *nix, but is not on
// Windows. Use _windows.go to provide atomic renames.