in common/src/main/java/jetbrains/buildServer/torrent/torrent/TorrentUtil.java [54:77]
public static File getOrCreateTorrent(@NotNull final File srcFile,
@NotNull final String relativePath,
@NotNull final File torrentsStore,
@NotNull final URI announceURI) {
File torrentFile = new File(torrentsStore, relativePath + TORRENT_FILE_SUFFIX);
if (torrentFile.isFile()) {
try {
TorrentMetadata t = loadTorrent(torrentFile);
List<List<String>> announceList = t.getAnnounceList() == null ?
Collections.singletonList(Collections.singletonList(t.getAnnounce())) :
t.getAnnounceList();
for (List<String> uris: announceList) {
if (uris.contains(announceURI.toString())) return torrentFile;
}
} catch (IOException e) {
LOG.warn("Failed to load existing torrent file: " + torrentFile.getAbsolutePath() + ", error: " + e.toString() + ". Will create new torrent file instead.");
}
}
final TorrentMetadata torrent = createTorrent(srcFile, torrentFile, announceURI);
return torrent != null ? torrentFile : null;
}