private void loadDb()

in common/src/main/java/jetbrains/buildServer/torrent/seeder/TorrentFilesDB.java [179:206]


  private void loadDb() throws IOException {
    // expecting rows to be sorted from oldest to newest,
    // then if max torrents limit is decreased newest entries will remove oldest in the cache automatically
    BufferedReader reader = null;
    try {
      InputStreamReader isReader = new InputStreamReader(new FileInputStream(myTorrentsDbFile), ENCODING);
      reader = new BufferedReader(isReader);
      String line;
      int counter = 0;
      LOG.info("try to load torrents from " + myTorrentsDbFile.getAbsolutePath());
      while ((line = reader.readLine()) != null) {
        List<String> paths = StringUtil.split(line, SEPARATOR);
        if (paths.size() != 2) continue;

        File srcFile = myPathConverter.convertToFile(paths.get(0));
        File torrentFile = myPathConverter.convertToFile(paths.get(1));

        counter++;
        addFileAndTorrent(srcFile, torrentFile);
      }
      LOG.info("Loaded " + counter + " torrents");
    } catch (FileNotFoundException e) {
      // no database on disk
      LOG.info("torrents.db file is not found in " + myTorrentsDbFile.getParent());
    } finally {
      FileUtil.close(reader);
    }
  }