Commit ab36d364 authored by Kevin Atkinson's avatar Kevin Atkinson

Remove temp file on error in writeDiskUsageFile.

parent 24e5fbe6
......@@ -868,6 +868,13 @@ func (fs *Datastore) checkpointLoop() {
func (fs *Datastore) writeDiskUsageFile(du int64, doSync bool) {
tmp, err := ioutil.TempFile(fs.path, "du-")
removed := false
defer func() {
if !removed {
// silence errcheck
_ = os.Remove(tmp.Name())
}
}()
if err != nil {
log.Warningf("cound not write disk usage: %v", err)
return
......@@ -897,6 +904,7 @@ func (fs *Datastore) writeDiskUsageFile(du int64, doSync bool) {
log.Warningf("cound not write disk usage: %v", err)
return
}
removed = true
fs.storedValue = toWrite
fs.dirty = false
......
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