mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-10 07:11:08 +00:00
Merge pull request #38 from kc1212/issue-37
Defer fd.Close() (fixes #37)
This commit is contained in:
commit
96afcd90e3
@ -95,6 +95,12 @@ func (s *statssrv) writeToFile(stats stats, secs float64) {
|
|||||||
log.Println("stats file:", err)
|
log.Println("stats file:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
err = fd.Close()
|
||||||
|
if err != nil {
|
||||||
|
log.Println("stats file:", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
bs, err := ioutil.ReadAll(fd)
|
bs, err := ioutil.ReadAll(fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -127,10 +133,4 @@ func (s *statssrv) writeToFile(stats stats, secs float64) {
|
|||||||
log.Println("stats file:", err)
|
log.Println("stats file:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = fd.Close()
|
|
||||||
if err != nil {
|
|
||||||
log.Println("stats file:", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user