public Path getForBackend()

in src/main/java/com/googlesource/gerrit/plugins/lfs/fs/LfsFsDataDirectoryManager.java [46:67]


  public Path getForBackend(LfsBackend backend, boolean ensure) throws IOException {
    String dataDir =
        configFactory.getGlobalConfig().getString(backend.type.name(), backend.name, KEY_DIRECTORY);
    if (Strings.isNullOrEmpty(dataDir)) {
      return defaultDataDir;
    }

    if (ensure) {
      // note that the following method not only creates missing
      // directory/directories but throws exception when path
      // exists and points to file
      Path ensured = Files.createDirectories(Paths.get(dataDir));

      // we should at least make sure that directory is readable
      if (!Files.isReadable(ensured)) {
        throw new IOException("Path '" + ensured.toAbsolutePath() + "' cannot be accessed");
      }

      return ensured;
    }
    return Paths.get(dataDir);
  }