From 4b7f858bee98bacd6ec6df1dbfe9c6afdd043c86 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Wed, 23 Oct 2013 18:40:02 -0400 Subject: [PATCH] Close() temp files before renaming them. Fixes syncing dirty wallet files on Windows. --- disksync.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/disksync.go b/disksync.go index 456b7db..997d815 100644 --- a/disksync.go +++ b/disksync.go @@ -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.