-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chanbackup: always close SCB file after reading #4456
Conversation
chanbackup/backupfile.go
Outdated
@@ -161,6 +161,9 @@ func (b *MultiFile) ExtractMulti(keyChain keychain.KeyRing) (*Multi, error) { | |||
if err != nil { | |||
return nil, err | |||
} | |||
if err := b.mainFile.Close(); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be deferred?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to not use ioutil.ReadFile
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to use ioutil.ReadFile
confirmed that it uses a defer close internally.
95f8dfb
to
fdd74e7
Compare
In this commit, we fix a bug introduced with the recent bug fix for SCB state+fail combination. On windwos a rename operation will fail is the fail one is attempting to rename is still open. Therefore we need to close the file after we read the contents, to ensure the follow up rename operations once the channel state changes will succeed. We do this by using `ioutil.ReadFile`, which will always clsoe the file after reading. Fixes lightningnetwork#4450.
fdd74e7
to
c58be56
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
In this commit, we fix a bug introduced with the recent bug fix for SCB
state+fail combination. On windwos a rename operation will fail is the
fail one is attempting to rename is still open. Therefore we need to
close the file after we read the contents, to ensure the follow up
rename operations once the channel state changes will succeed.
Fixes #4450.