code: func (ms *FileMsgStore) beforeDataFileCloseCb(fslice *fileSlice) beforeFileClose {
  	return func() error {
  		if fslice != ms.writeSlice {
  			return nil
  		}
  		if ms.bw != nil && ms.bw.buf != nil && ms.bw.buf.Buffered() > 0 {
  			if err := ms.bw.buf.Flush(); err != nil {
  				return err
  			}
  		}
  		if ms.fstore.opts.DoSync {
  			if err := fslice.file.handle.Sync(); err != nil {
  				return err
  			}
  		}
  		ms.writer = nil
  		return nil
  	}
  }
docs: // beforeDataFileCloseCb returns a beforeFileClose callback to be used
  // by FileMsgStore's files when a data file for that slice is being closed.
  // This is invoked asynchronously and should not acquire the store's lock.
  // That being said, we have the guarantee that this will be not be invoked
  // concurrently for a given file and that the store will not be using this file.