Unverified Commit 99c0640e authored by Kevin Atkinson's avatar Kevin Atkinson Committed by GitHub

Merge pull request #47 from b5/switch_defer

check error before defer-removing disk usage file
parents d25f80d9 21dc9bb7
...@@ -863,6 +863,11 @@ func (fs *Datastore) checkpointLoop() { ...@@ -863,6 +863,11 @@ func (fs *Datastore) checkpointLoop() {
func (fs *Datastore) writeDiskUsageFile(du int64, doSync bool) { func (fs *Datastore) writeDiskUsageFile(du int64, doSync bool) {
tmp, err := ioutil.TempFile(fs.path, "du-") tmp, err := ioutil.TempFile(fs.path, "du-")
if err != nil {
log.Warningf("cound not write disk usage: %v", err)
return
}
removed := false removed := false
defer func() { defer func() {
if !removed { if !removed {
...@@ -870,10 +875,6 @@ func (fs *Datastore) writeDiskUsageFile(du int64, doSync bool) { ...@@ -870,10 +875,6 @@ func (fs *Datastore) writeDiskUsageFile(du int64, doSync bool) {
_ = os.Remove(tmp.Name()) _ = os.Remove(tmp.Name())
} }
}() }()
if err != nil {
log.Warningf("cound not write disk usage: %v", err)
return
}
toWrite := fs.storedValue toWrite := fs.storedValue
toWrite.DiskUsage = du toWrite.DiskUsage = du
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment