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() {
func (fs *Datastore) writeDiskUsageFile(du int64, doSync bool) {
tmp, err := ioutil.TempFile(fs.path, "du-")
if err != nil {
log.Warningf("cound not write disk usage: %v", err)
return
}
removed := false
defer func() {
if !removed {
......@@ -870,10 +875,6 @@ func (fs *Datastore) writeDiskUsageFile(du int64, doSync bool) {
_ = os.Remove(tmp.Name())
}
}()
if err != nil {
log.Warningf("cound not write disk usage: %v", err)
return
}
toWrite := fs.storedValue
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