Pochatkin commented on code in PR #7402:
URL: https://github.com/apache/ignite-3/pull/7402#discussion_r2686902723
##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/call/cluster/unit/DeployUnitCall.java:
##########
@@ -64,27 +67,52 @@ public CompletableFuture<CallOutput<String>>
execute(DeployUnitCallInput input)
if (Files.notExists(path)) {
return completedFuture(DefaultCallOutput.failure(new
FileNotFoundException(path.toString())));
}
+
+ DeploymentContent content;
+ try {
+ content = input.recursive() ? createZipContent(path) :
createFilesContent(path);
Review Comment:
Fixed
##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/call/cluster/unit/DeployUnitCall.java:
##########
@@ -96,6 +124,95 @@ public CompletableFuture<CallOutput<String>>
execute(DeployUnitCallInput input)
});
}
+ private static File createZipFromDirectory(Path sourceDir) throws
IOException {
+ Path zipPath = Files.createTempFile("deploy-unit-", ".zip");
+ try (OutputStream os = Files.newOutputStream(zipPath);
+ ZipOutputStream zos = new ZipOutputStream(os)) {
+ try (Stream<Path> stream = Files.walk(sourceDir)) {
+ stream.filter(Files::isRegularFile).forEach(filePath -> {
+ Path relativePath = sourceDir.relativize(filePath);
+ try {
+ ZipEntry zipEntry = new
ZipEntry(relativePath.toString().replace('\\', '/'));
+ zos.putNextEntry(zipEntry);
+ Files.copy(filePath, zos);
+ zos.closeEntry();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to add file to ZIP:
" + filePath, e);
Review Comment:
Fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]