in deploy-runner-agent-smb2/src/main/java/jetbrains/buildServer/deployer/agent/smb/SMBJBuildProcessAdapter.java [186:235]
private int upload(Map<File, String> filePathMap, DiskShare share, String prefixPath) throws IOException {
int count = 0;
Map<File, String> fileFullPathMap = new HashMap<>();
if (prefixPath.length() > 0) {
for (Map.Entry<File, String> entry : filePathMap.entrySet()) {
fileFullPathMap.put(entry.getKey(), prefixPath + "\\" + entry.getValue());
}
} else {
fileFullPathMap.putAll(filePathMap);
}
for (Map.Entry<File, String> fileDestEntry : fileFullPathMap.entrySet()) {
checkIsInterrupted();
final File source = fileDestEntry.getKey();
final String targetPath = fileDestEntry.getValue().replace('/', '\\');
maybeCreate(share, targetPath);
final String targetName = (targetPath.length() > 0 ? targetPath + "\\" : "") + source.getName();
final com.hierynomus.smbj.share.File targetFile = share.openFile(targetName,
EnumSet.of(AccessMask.GENERIC_WRITE),
null,
SMB2ShareAccess.ALL,
FILE_OVERWRITE_IF,
null);
Loggers.AGENT.debug("Uploading source=[" + source.getAbsolutePath() + "] to \n" +
" destFile=[" + targetName + "]");
FileInputStream inputStream = null;
OutputStream outputStream = null;
try {
inputStream = new FileInputStream(source);
outputStream = targetFile.getOutputStream();
copyInterruptibly(inputStream, outputStream);
outputStream.flush();
} finally {
FileUtil.close(inputStream);
FileUtil.close(outputStream);
targetFile.close();
}
LOG.debug("Done transferring [" + source.getAbsolutePath() + "]");
count++;
}
return count;
}