mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
accounts: retry account renaming to avoid sync races
This commit is contained in:
parent
80ea44c485
commit
3980d3bf47
1 changed files with 7 additions and 1 deletions
|
|
@ -207,7 +207,13 @@ func writeKeyFile(file string, content []byte) error {
|
|||
return err
|
||||
}
|
||||
f.Close()
|
||||
return os.Rename(f.Name(), file)
|
||||
|
||||
if err := os.Rename(f.Name(), file); err != nil {
|
||||
// Renaming failed, may be a data race between a cache sync, retry
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
return os.Rename(f.Name(), file)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// keyFileName implements the naming convention for keyfiles:
|
||||
|
|
|
|||
Loading…
Reference in a new issue