code: func (fs *FileStore) compactClientFile(orgFileName string) error {
  	// Open a temporary file
  	tmpFile, err := getTempFile(fs.fm.rootDir, clientsFileName)
  	if err != nil {
  		return err
  	}
  	defer func() {
  		if tmpFile != nil {
  			tmpFile.Close()
  			os.Remove(tmpFile.Name())
  		}
  	}()
  	bw := bufio.NewWriterSize(tmpFile, defaultBufSize)
  	fileSize := int64(0)
  	size := 0
  	_buf := [256]byte{}
  	buf := _buf[:]
  	// Dump the content of active clients into the temporary file.
  	for _, c := range fs.clients {
  		buf, size, err = writeRecord(bw, buf, addClient, &c.ClientInfo, c.ClientInfo.Size(), fs.crcTable)
  		if err != nil {
  			return err
  		}
  		fileSize += int64(size)
  	}
  	// Flush the buffer on disk
  	if err := bw.Flush(); err != nil {
  		return err
  	}
  	// Start by closing the temporary file.
  	if err := tmpFile.Close(); err != nil {
  		return err
  	}
  	// Rename the tmp file to original file name
  	if err := os.Rename(tmpFile.Name(), orgFileName); err != nil {
  		return err
  	}
  	// Avoid unnecessary attempt to cleanup
  	tmpFile = nil
  
  	fs.cliDeleteRecs = 0
  	fs.cliFileSize = fileSize
  	fs.cliCompactTS = time.Now()
  	return nil
  }
docs: // Rewrite the content of the clients map into a temporary file,
  // then swap back to active file.
  // Store lock held on entry