mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 21:26:42 +00:00
triedb/pathdb: fix error handling in journal cleanup defer function
This commit is contained in:
parent
471b18de18
commit
d8419ffca2
1 changed files with 8 additions and 3 deletions
|
|
@ -362,10 +362,15 @@ func (db *Database) Journal(root common.Hash) error {
|
|||
}
|
||||
defer func() {
|
||||
if file != nil {
|
||||
file.Close()
|
||||
os.Remove(tmp) // Clean up temp file if we didn't successfully rename it
|
||||
if err := file.Close(); err != nil {
|
||||
log.Warn("Failed to close temporary journal file", "path", tmp, "err", err)
|
||||
}
|
||||
if err := os.Remove(tmp); err != nil {
|
||||
log.Warn("Failed to remove leftover temporary journal file", "path", tmp, "err", err)
|
||||
} else {
|
||||
log.Warn("Removed leftover temporary journal file", "path", tmp)
|
||||
}
|
||||
}
|
||||
}()
|
||||
journal = file
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue