Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5a21fc1

Browse files
committedSep 10, 2018
check error before defer-removing disk usage file
1 parent d25f80d commit 5a21fc1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎flatfs.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -864,16 +864,17 @@ func (fs *Datastore) checkpointLoop() {
864864
func (fs *Datastore) writeDiskUsageFile(du int64, doSync bool) {
865865
tmp, err := ioutil.TempFile(fs.path, "du-")
866866
removed := false
867+
if err != nil {
868+
log.Warningf("cound not write disk usage: %v", err)
869+
return
870+
}
871+
867872
defer func() {
868873
if !removed {
869874
// silence errcheck
870875
_ = os.Remove(tmp.Name())
871876
}
872877
}()
873-
if err != nil {
874-
log.Warningf("cound not write disk usage: %v", err)
875-
return
876-
}
877878

878879
toWrite := fs.storedValue
879880
toWrite.DiskUsage = du

0 commit comments

Comments
 (0)
Please sign in to comment.