diff --git a/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/PackagesImpl.java b/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/PackagesImpl.java index 2b0ce92a54c73..d32bd308e4f5f 100644 --- a/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/PackagesImpl.java +++ b/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/PackagesImpl.java @@ -25,6 +25,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; import java.util.List; import java.util.concurrent.CompletableFuture; import javax.ws.rs.client.Entity; @@ -144,7 +145,7 @@ public void completed(Response response) { if (destinyPath.getParent() != null) { Files.createDirectories(destinyPath.getParent()); } - Files.copy(inputStream, destinyPath); + Files.copy(inputStream, destinyPath, StandardCopyOption.REPLACE_EXISTING); future.complete(null); } catch (IOException e) { future.completeExceptionally(e); diff --git a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java index 5fbf98dca81f4..63b1b33268403 100644 --- a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java +++ b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java @@ -815,6 +815,7 @@ static File downloadPackageFile(PulsarWorkerService worker, String packageName) // use the Nar extraction directory as a temporary directory for downloaded files tempDirectory = Paths.get(worker.getWorkerConfig().getNarExtractionDirectory()); } + Files.createDirectories(tempDirectory); File file = Files.createTempFile(tempDirectory, "function", ".tmp").toFile(); worker.getBrokerAdmin().packages().download(packageName, file.toString()); return file;