Skip to content

Commit ff07d74

Browse files
committed
optimize upload of classpath
Signed-off-by: Ludovic Orban <[email protected]>
1 parent 139c6c0 commit ff07d74

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

src/main/java/org/mortbay/jetty/orchestrator/configuration/SshRemoteHostLauncher.java

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -250,42 +250,14 @@ private static List<String> filterOutEmptyStrings(List<String> opts)
250250
private static void copyFile(SftpClient sftpClient, String hostId, String filename, File localSourceFile) throws Exception
251251
{
252252
String destFilename = "." + NodeFileSystemProvider.PREFIX + "/" + hostId + "/" + NodeProcess.CLASSPATH_FOLDER_NAME + "/" + filename;
253-
String parentFilename = destFilename.substring(0, destFilename.lastIndexOf('/'));
254253

255-
mkdirs(sftpClient, parentFilename);
256254
try (OutputStream os = sftpClient.write(destFilename);
257255
FileInputStream is = new FileInputStream(localSourceFile))
258256
{
259257
IOUtil.copy(is, os);
260258
}
261259
}
262260

263-
private static void mkdirs(SftpClient sftpClient, String parentFilename) throws IOException
264-
{
265-
boolean exists = true;
266-
StringBuilder cwd = new StringBuilder();
267-
for (String dirName : parentFilename.split("/"))
268-
{
269-
cwd.append(dirName);
270-
if (exists)
271-
{
272-
try
273-
{
274-
sftpClient.lstat(cwd.toString());
275-
}
276-
catch (IOException ioe)
277-
{
278-
exists = false;
279-
}
280-
}
281-
282-
if (!exists)
283-
sftpClient.mkdir(cwd.toString());
284-
285-
cwd.append("/");
286-
}
287-
}
288-
289261
private static void copyDir(SftpClient sftpClient, String hostId, File cpFile, int depth) throws Exception
290262
{
291263
File[] files = cpFile.listFiles();
@@ -296,6 +268,14 @@ private static void copyDir(SftpClient sftpClient, String hostId, File cpFile, i
296268
{
297269
if (file.isDirectory())
298270
{
271+
try
272+
{
273+
sftpClient.lstat(file.getName());
274+
}
275+
catch (IOException e)
276+
{
277+
sftpClient.mkdir(file.getName());
278+
}
299279
copyDir(sftpClient, hostId, file, depth + 1);
300280
}
301281
else

0 commit comments

Comments
 (0)