@SuppressWarnings("java:S2139")
  private void moveModFile(File modFileToLoad, File targetModFile, boolean deleteOriginFile)
      throws LoadFileException {
    if (modFileToLoad.exists()) {
      // when successfully loaded, the filepath of the resource will be changed to the IoTDB data
      // dir, so we can add a suffix to find the old modification file.
      try {
        RetryUtils.retryOnException(
            () -> {
              Files.deleteIfExists(targetModFile.toPath());
              return null;
            });
      } catch (final IOException e) {
        logger.warn("Cannot delete localModFile {}", targetModFile, e);
      }
      try {
        if (deleteOriginFile) {
          RetryUtils.retryOnException(
              () -> {
                FileUtils.moveFile(modFileToLoad, targetModFile);
                return null;
              });
        } else {
          RetryUtils.retryOnException(
              () -> {
                Files.copy(modFileToLoad.toPath(), targetModFile.toPath());
                return null;
              });
        }
      } catch (final IOException e) {
        logger.warn(
            "File renaming failed when loading .mod file. Origin: {}, Target: {}",
            modFileToLoad.getAbsolutePath(),
            targetModFile.getAbsolutePath(),
            e);
        throw new LoadFileException(
            String.format(
                "File renaming failed when loading .mod file. Origin: %s, Target: %s, because %s",
                modFileToLoad.getAbsolutePath(), targetModFile.getAbsolutePath(), e.getMessage()));
      }
    }
  }
Execute the loading process by the type.

@param tsFileResource tsfile resource to be loaded
@param filePartitionId the partition id of the new file
@param deleteOriginFile whether to delete the original file
@return load the file successfully @UsedBy sync module, load external tsfile module.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java