public List<File> doCheck() throws WALException {
    File walFolderFile = SystemFileFactory.INSTANCE.getFile(walFolder);
    logger.info("Checking folder: {}", walFolderFile.getAbsolutePath());
    if (!walFolderFile.exists() || !walFolderFile.isDirectory()) {
      throw new WALException(walFolder);
    }

    File[] walNodeFolders = walFolderFile.listFiles(File::isDirectory);
    if (walNodeFolders == null || walNodeFolders.length == 0) {
      logger.info("No sub-directories under the given directory, check ends");
      return Collections.emptyList();
    }

    List<File> failedFiles = new ArrayList<>();
    for (int dirIndex = 0; dirIndex < walNodeFolders.length; dirIndex++) {
      File walNodeFolder = walNodeFolders[dirIndex];
      logger.info("Checking the No.{} directory {}", dirIndex, walNodeFolder.getName());
      File[] walFiles = WALFileUtils.listAllWALFiles(walNodeFolder);
      if (walFiles == null) {
        continue;
      }
      for (File walFile : walFiles) {
        if (!checkFile(walFile)) {
          failedFiles.add(walFile);
        }
      }
    }
    return failedFiles;
  }
check the root wal dir and find the damaged files

@return a list of damaged files.
@throws WALException if the root wal dir does not exist.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/tools/WalChecker.java