in deploy-runner-agent-smb/src/main/java/jetbrains/buildServer/deployer/agent/smb/SMBBuildProcessAdapter.java [107:146]
private int upload(Map<File, String> filePathMap, SmbFile destination) throws IOException {
int count = 0;
for (Map.Entry<File, String> fileDestEntry : filePathMap.entrySet()) {
checkIsInterrupted();
final File source = fileDestEntry.getKey();
final String targetPath = fileDestEntry.getValue();
final SmbFile destDirectory;
if (StringUtil.isEmpty(targetPath)) {
destDirectory = destination;
} else {
destDirectory = new SmbFile(destination, targetPath + "/");
}
final SmbFile destFile = new SmbFile(destDirectory, source.getName());
Loggers.AGENT.debug("Uploading source=[" + source.getAbsolutePath() + "] to \n" +
"destDirectory=[" + destDirectory.getCanonicalPath() +
"] destFile=[" + destFile.getCanonicalPath() + "]");
FileInputStream inputStream = null;
OutputStream outputStream = null;
LOG.debug("Transferring [" + source.getAbsolutePath() + "] to [" + destDirectory.getCanonicalPath() + "] destFile=[" + destFile.getCanonicalPath() + "]");
try {
if (!destDirectory.exists()) {
destDirectory.mkdirs();
}
inputStream = new FileInputStream(source);
outputStream = destFile.getOutputStream();
copyInterruptibly(inputStream, outputStream);
outputStream.flush();
} finally {
FileUtil.close(inputStream);
FileUtil.close(outputStream);
}
LOG.debug("Done transferring [" + source.getAbsolutePath() + "]");
count++;
}
return count;
}