def _commit_toc(self, segments): from whoosh.index import TOC, clean_files # Write a new TOC with the new segment list (and delete old files) toc = TOC(self.schema, segments, self.generation) toc.write(self.storage, self.indexname) # Delete leftover files clean_files(self.storage, self.indexname, self.generation, segments)