in agent/src/main/java/jetbrains/buildServer/torrent/TorrentArtifactCacheListener.java [129:152]
private void createTorrentFileCopyAndAddAsArtifact(@NotNull File torrentFile,
@NotNull final File file,
@NotNull final File cacheCurrentBuildDir) {
String artifactDirs = FileUtil.getRelativePath(cacheCurrentBuildDir, file.getParentFile());
if (artifactDirs == null) {
LOG.warn(String.format("Unable to find relative path to artifact %s. " +
"Torrent file was not created for this artifact. Nobody can download the aftifact via bittorrent", file.getAbsolutePath()));
return;
}
File torrentsTempDirectory = new File(myBuildTracker.getCurrentBuild().getBuildTempDirectory(), Constants.TORRENT_FILE_COPIES_DIR);
File dirForTorrentCopy = new File(torrentsTempDirectory, artifactDirs);
File torrentFileCopy = new File(dirForTorrentCopy, file.getName() + TorrentUtil.TORRENT_FILE_SUFFIX);
try {
torrentFileCopy = torrentFileCopy.getCanonicalFile();
FileUtils.copyFile(torrentFile, torrentFileCopy);
} catch (IOException e) {
LOG.debug("error in copy torrent file", e);
return;
}
String torrentArtifactPath = createArtifactPath(torrentFileCopy, Constants.TORRENTS_DIR_ON_SERVER + artifactDirs);
myTorrentsManager.saveTorrentForPublish(torrentArtifactPath);
}