code: func (fd *IndexFileDeleter) refresh(segmentName string) error {
  	// assert locked()
  
  	var prefix1, prefix2 string
  	if segmentName != "" {
  		prefix1 = segmentName + "."
  		prefix2 = segmentName + "_"
  	}
  
  	m := model.CODEC_FILE_PATTERN
  	files, err := fd.directory.ListAll()
  	if err != nil {
  		return err
  	}
  	for _, filename := range files {
  		_, hasRef := fd.refCounts[filename]
  		if (segmentName == "" || strings.HasPrefix(filename, prefix1) ||
  			strings.HasPrefix(filename, prefix2)) &&
  			!strings.HasSuffix(filename, WRITE_LOCK_NAME) &&
  			!hasRef && filename != INDEX_FILENAME_SEGMENTS_GEN &&
  			(m.MatchString(filename) || strings.HasPrefix(filename, INDEX_FILENAME_SEGMENTS)) {
  
  			// Unreferenced file, so remove it
  			if fd.infoStream.IsEnabled("IFD") {
  				fd.infoStream.Message("IFD",
  					"refresh [prefix=%v]: removing newly created unreferenced file '%v'",
  					segmentName, filename)
  			}
  			fd.deleteFile(filename)
  		}
  	}
  	return nil
  }
docs: /*
  Writer calls this when it has hit an error and had to roll back, to
  tell us that there may now be unreferenced files in the filesystem.
  So we re-list the filesystem and delete such files. If segmentName is
  non-empty, we only delete files correspoding to that segment.
  */