mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 03:18:59 +00:00
Defer fd.Close() (fixes #37)
This commit is contained in:
parent
2e44473ce4
commit
ea61f8f597
@ -95,6 +95,12 @@ func (s *statssrv) writeToFile(stats stats, secs float64) {
|
||||
log.Println("stats file:", err)
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
err = fd.Close()
|
||||
if err != nil {
|
||||
log.Println("stats file:", err)
|
||||
}
|
||||
}()
|
||||
|
||||
bs, err := ioutil.ReadAll(fd)
|
||||
if err != nil {
|
||||
@ -127,10 +133,4 @@ func (s *statssrv) writeToFile(stats stats, secs float64) {
|
||||
log.Println("stats file:", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = fd.Close()
|
||||
if err != nil {
|
||||
log.Println("stats file:", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user