You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by la...@apache.org on 2023/08/18 06:33:32 UTC

[iotdb] 02/02: Override existing jar instead of deleting it when registering UDF

This is an automated email from the ASF dual-hosted git repository.

lancelly pushed a commit to branch udf_win
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 8cf8bb671a554a990bec5e28fd069ae254e61bf1
Author: Liao Lanyu <14...@qq.com>
AuthorDate: Fri Aug 18 09:41:19 2023 +0800

    Override existing jar instead of deleting it when registering UDF
---
 .../apache/iotdb/commons/executable/ExecutableManager.java    | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/node-commons/src/main/java/org/apache/iotdb/commons/executable/ExecutableManager.java b/node-commons/src/main/java/org/apache/iotdb/commons/executable/ExecutableManager.java
index 0f195086230..4a730d2a5fa 100644
--- a/node-commons/src/main/java/org/apache/iotdb/commons/executable/ExecutableManager.java
+++ b/node-commons/src/main/java/org/apache/iotdb/commons/executable/ExecutableManager.java
@@ -223,11 +223,18 @@ public class ExecutableManager {
     }
   }
 
+  /**
+   * Create and save the file if the specified file does not exist, or this method will override the
+   * existing file.
+   */
   protected void saveToDir(ByteBuffer byteBuffer, String destination) throws IOException {
     try {
       Path path = Paths.get(destination);
-      Files.deleteIfExists(path);
-      Files.createFile(path);
+      if (!Files.exists(path)) {
+        Files.createFile(path);
+      }
+      // FileOutPutStream is not in append mode by default, so the file will be overridden if it
+      // already exists.
       try (FileOutputStream outputStream = new FileOutputStream(destination)) {
         outputStream.getChannel().write(byteBuffer);
       }