mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-24 14:50:40 +01:00
Merge pull request #3129 from Roasbeef/scb-fix-windows
chanbackup: close temp SCB file before rename
This commit is contained in:
commit
cd285d6bb8
1 changed files with 7 additions and 0 deletions
|
@ -113,6 +113,13 @@ func (b *MultiFile) UpdateAndSwap(newBackup PackedMulti) error {
|
|||
log.Infof("Swapping old multi backup file from %v to %v",
|
||||
b.tempFileName, b.fileName)
|
||||
|
||||
// Before we rename the swap (atomic name swap), we'll make
|
||||
// sure to close the current file as some OSes don't support
|
||||
// renaming a file that's already open (Windows).
|
||||
if err := b.tempFile.Close(); err != nil {
|
||||
return fmt.Errorf("unable to close file: %v", err)
|
||||
}
|
||||
|
||||
// Finally, we'll attempt to atomically rename the temporary file to
|
||||
// the main back up file. If this succeeds, then we'll only have a
|
||||
// single file on disk once this method exits.
|
||||
|
|
Loading…
Add table
Reference in a new issue