code: private void moveFromTempToPerm() throws IOException {
      try {
        FileStatus[] fileStatus =
            localFs.listStatus(temp, LuceneIndexFileNameFilter.getFilter());
        Path segmentsPath = null;
        Path segmentsGenPath = null;
  
        // move the files created in temp dir except segments_N and segments.gen
        for (int i = 0; i < fileStatus.length; i++) {
          Path path = fileStatus[i].getPath();
          String name = path.getName();
  
          if (LuceneUtil.isSegmentsGenFile(name)) {
            assert (segmentsGenPath == null);
            segmentsGenPath = path;
          } else if (LuceneUtil.isSegmentsFile(name)) {
            assert (segmentsPath == null);
            segmentsPath = path;
          } else {
            fs.completeLocalOutput(new Path(perm, name), path);
          }
        }
  
        // move the segments_N file
        if (segmentsPath != null) {
          fs.completeLocalOutput(new Path(perm, segmentsPath.getName()),
              segmentsPath);
        }
  
        // move the segments.gen file
        if (segmentsGenPath != null) {
          fs.completeLocalOutput(new Path(perm, segmentsGenPath.getName()),
              segmentsGenPath);
        }
      } finally {
        // finally delete the temp dir (files should have been deleted)
        localFs.delete(temp);
      }
    }
docs: and then delete the temp dir from the local FS