in agent/src/main/java/jetbrains/buildServer/torrent/TorrentArtifactCacheListener.java [68:119]
public void onAfterAddOrUpdate(@NotNull File file) {
if (isTorrentFile(file)) return;
if (isTeamcityIVYFile(file)) return;
final String absolutePath = file.getAbsolutePath();
if (!myTorrentsManager.isTransportEnabled()) {
LOG.debug("Torrent plugin disabled. Won't seed " + absolutePath);
return;
}
if (!TorrentUtil.shouldCreateTorrentFor(file.length(), myConfiguration)) {
LOG.debug("Won't create torrent for " + absolutePath + ". Artifact is too small: " + file.length());
return;
}
String announceUrl = myConfiguration.getAnnounceUrl();
if (announceUrl == null) return;
TorrentMetadata metadata;
try {
metadata = TorrentCreator.create(file, URI.create(announceUrl), "TeamCity Torrent Plugin");
} catch (Exception e) {
return;
}
if (myTorrentsSeeder.getClient().isSeeding(metadata)) {
LOG.debug("Already seeding " + absolutePath);
return;
}
File cacheCurrentBuildDir;
try {
cacheCurrentBuildDir = getCurrentBuildFolderCache();
} catch (NoRunningBuildException e) {
logWarningThatCacheCurrentBuildNotFound(absolutePath);
return;
}
if (cacheCurrentBuildDir == null) {
logWarningThatCacheCurrentBuildNotFound(absolutePath);
return;
}
if (!isChildFile(cacheCurrentBuildDir, file)) {
//reference to parent in relative path means that it is artifact from other build. We can skip it
return;
}
File createdTorrentFile = publishTorrentFileAndStartSeeding(file);
if (createdTorrentFile == null) {
return;
}
createTorrentFileCopyAndAddAsArtifact(createdTorrentFile, file, cacheCurrentBuildDir);
}