You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2020/04/11 12:30:26 UTC

[incubator-doris] branch master updated: [Bug] Fix bug that user plugin dir is removed after installing the plugin (#3302)

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

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 5b69c70  [Bug] Fix bug that user plugin dir is removed after installing the plugin (#3302)
5b69c70 is described below

commit 5b69c70f9aa64f00b6e11483864e0fe9100f6973
Author: Mingyu Chen <mo...@gmail.com>
AuthorDate: Sat Apr 11 20:30:14 2020 +0800

    [Bug] Fix bug that user plugin dir is removed after installing the plugin (#3302)
    
    When user install a FE plugin from a directory, the directory should not
    be removed after installing.
---
 fe/src/main/java/org/apache/doris/plugin/DynamicPluginLoader.java | 6 +++---
 fe/src/main/java/org/apache/doris/plugin/PluginZip.java           | 7 +++++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/fe/src/main/java/org/apache/doris/plugin/DynamicPluginLoader.java b/fe/src/main/java/org/apache/doris/plugin/DynamicPluginLoader.java
index 6302e56..2ad494c 100644
--- a/fe/src/main/java/org/apache/doris/plugin/DynamicPluginLoader.java
+++ b/fe/src/main/java/org/apache/doris/plugin/DynamicPluginLoader.java
@@ -79,17 +79,17 @@ public class DynamicPluginLoader extends PluginLoader {
                 PluginZip zip = new PluginZip(source);
                 // generation a tmp dir to extract the zip
                 tmpTarget = Files.createTempDirectory(pluginDir, ".install_");
-                // for now, installPath point to the temp dir which contains all extracted files from zip file.
+                // for now, installPath point to the temp dir which contains
+                // all files extracted from zip or copied from user specified dir.
                 installPath = zip.extract(tmpTarget);
             }
             pluginInfo = PluginInfo.readFromProperties(installPath, source);
         } catch (Exception e) {
             if (tmpTarget != null) {
-                Files.delete(tmpTarget);
+                FileUtils.deleteQuietly(tmpTarget.toFile());
             }
             throw e;
         }
-
         return pluginInfo;
     }
 
diff --git a/fe/src/main/java/org/apache/doris/plugin/PluginZip.java b/fe/src/main/java/org/apache/doris/plugin/PluginZip.java
index b40ea23..2120bb3 100644
--- a/fe/src/main/java/org/apache/doris/plugin/PluginZip.java
+++ b/fe/src/main/java/org/apache/doris/plugin/PluginZip.java
@@ -141,7 +141,8 @@ class PluginZip {
     }
 
     /**
-     * unzip the specified .zip file "zip" to the target path
+     * if `zipOrPath` is a zip file, unzip the specified .zip file to the targetPath.
+     * if `zipOrPath` is a dir, copy the dir and its content to targetPath.
      */
     Path extractZip(Path zip, Path targetPath) throws IOException, UserException {
         if (!Files.exists(zip)) {
@@ -149,7 +150,9 @@ class PluginZip {
         }
 
         if (Files.isDirectory(zip)) {
-            return zip;
+            // user install the plugin by dir/, so just copy the dir to the target path
+            FileUtils.copyDirectory(zip.toFile(), targetPath.toFile());
+            return targetPath;
         }
 
         try (ZipInputStream zipInput = new ZipInputStream(Files.newInputStream(zip))) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org