private Path get()

in src/main/java/jetbrains/buildServer/investigationsAutoAssigner/persistent/AssignerResultsFilePath.java [33:64]


  private Path get(@NotNull final SBuild build,
                   boolean createIfNotExist,
                   @Nullable final STestRun testRun) throws IOException {
    Path artifactDirectoryPath = build.getArtifactsDirectory().toPath();
    Path teamcityDirectoryPath = artifactDirectoryPath.resolve(Constants.TEAMCITY_DIRECTORY);
    if (!Files.exists(teamcityDirectoryPath)) {
      Constants.LOGGER.debug("Skip investigation suggestion logic for " +
                             (testRun != null ? LogUtil.describe(testRun) : " test runs ") +
                             " as " + teamcityDirectoryPath + " doesn't exists.");
      return null;
    }

    Path autoAssignerDirectoryPath = teamcityDirectoryPath.resolve(Constants.ARTIFACT_DIRECTORY);
    if (!Files.exists(autoAssignerDirectoryPath)) {
      if (createIfNotExist) {
        Files.createDirectory(autoAssignerDirectoryPath);
      } else {
        return null;
      }
    }

    Path resultsPath = autoAssignerDirectoryPath.resolve(Constants.ARTIFACT_FILENAME);
    if (!Files.exists(resultsPath)) {
      if (createIfNotExist) {
        Files.createFile(resultsPath);
      } else {
        return null;
      }
    }

    return resultsPath;
  }