code: func (p *Partition) writeStatsFile() error {
  	tmpPath := p.StatsPath() + ".tmp"
  	f, err := os.Create(tmpPath)
  	if err != nil {
  		return err
  	}
  	defer f.Close()
  
  	n, err := p.stats.WriteTo(f)
  	if err != nil {
  		return err
  	}
  
  	if err := f.Close(); err != nil {
  		return err
  	} else if err := os.Rename(tmpPath, p.StatsPath()); err != nil {
  		return err
  	}
  
  	p.statsSize = n
  	return nil
  }
docs: // writeStatsFile writes the stats file and updates the stats size.