Add atomic rename functions for Windows and Plan 9.
This code is based off leveldb (https://github.com/syndtr/goleveldb), and the leveldb copyright notice (a 2-clause BSD license) has been included where used.
This commit is contained in:
parent
311276eae5
commit
e7826dae00
5 changed files with 151 additions and 6 deletions
|
@ -149,7 +149,7 @@ func (a *Account) writeDirtyToDisk() error {
|
|||
|
||||
// TODO(jrick): this should be atomic on *nix, but is not on
|
||||
// Windows. Use _windows.go to provide atomic renames.
|
||||
if err = os.Rename(tmpfilepath, utxofilepath); err != nil {
|
||||
if err = Rename(tmpfilepath, utxofilepath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ func (a *Account) writeDirtyToDisk() error {
|
|||
|
||||
// TODO(jrick): this should be atomic on *nix, but is not on
|
||||
// Windows. Use _windows.go to provide atomic renames.
|
||||
if err = os.Rename(tmpfilepath, txfilepath); err != nil {
|
||||
if err = Rename(tmpfilepath, txfilepath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ func (a *Account) writeDirtyToDisk() error {
|
|||
|
||||
// TODO(jrick): this should be atomic on *nix, but is not on
|
||||
// Windows. Use _windows.go to provide atomic renames.
|
||||
if err = os.Rename(tmpfilepath, wfilepath); err != nil {
|
||||
if err = Rename(tmpfilepath, wfilepath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue