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

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


The following commit(s) were added to refs/heads/master by this push:
     new 36920fc  HOP-3436 use project base folder as zip root
     new 0668e36  Merge pull request #1242 from bamaer/HOP-3436
36920fc is described below

commit 36920fcb2a19a4edf12c1aab27b64e5e39070bca
Author: Bart Maertens <[email protected]>
AuthorDate: Wed Dec 22 20:47:24 2021 +0100

    HOP-3436 use project base folder as zip root
---
 .../java/org/apache/hop/projects/gui/ProjectsGuiPlugin.java | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git 
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/gui/ProjectsGuiPlugin.java
 
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/gui/ProjectsGuiPlugin.java
index 8b2c5c5..7f52c11 100644
--- 
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/gui/ProjectsGuiPlugin.java
+++ 
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/gui/ProjectsGuiPlugin.java
@@ -991,7 +991,8 @@ public class ProjectsGuiPlugin {
               OutputStream outputStream = HopVfs.getOutputStream(zipFilename, 
false);
               ZipOutputStream zos = new ZipOutputStream(outputStream);
               FileObject projectDirectory = HopVfs.getFileObject(projectHome);
-              zipFile(projectDirectory, projectDirectory.getName().getURI(), 
zos);
+              String projectHomeFolder = 
HopVfs.getFileObject(projectHome).getParent().getName().getURI();
+              zipFile(projectDirectory, projectDirectory.getName().getURI(), 
zos, projectHomeFolder);
               zos.close();
               outputStream.close();
               monitor.done();
@@ -1021,27 +1022,27 @@ public class ProjectsGuiPlugin {
     }
   }
 
-  public void zipFile(FileObject fileToZip, String filename, ZipOutputStream 
zipOutputStream)
+  public void zipFile(FileObject fileToZip, String filename, ZipOutputStream 
zipOutputStream, String projectHomeParent)
       throws IOException {
     if (fileToZip.isHidden()) {
       return;
     }
     if (fileToZip.isFolder()) {
       if (filename.endsWith("/")) {
-        zipOutputStream.putNextEntry(new ZipEntry(filename));
+        zipOutputStream.putNextEntry(new 
ZipEntry(filename.replaceAll(projectHomeParent, "")));
         zipOutputStream.closeEntry();
       } else {
-        zipOutputStream.putNextEntry(new ZipEntry(filename + "/"));
+        zipOutputStream.putNextEntry(new 
ZipEntry(filename.replaceAll(projectHomeParent, "") + "/"));
         zipOutputStream.closeEntry();
       }
       FileObject[] children = fileToZip.getChildren();
       for (FileObject childFile : children) {
-        zipFile(childFile, filename + "/" + childFile.getName().getBaseName(), 
zipOutputStream);
+        zipFile(childFile, filename + "/" + childFile.getName().getBaseName(), 
zipOutputStream, projectHomeParent);
       }
       return;
     }
     InputStream fis = HopVfs.getInputStream(fileToZip);
-    ZipEntry zipEntry = new ZipEntry(filename);
+    ZipEntry zipEntry = new ZipEntry(filename.replaceAll(projectHomeParent, 
""));
     zipOutputStream.putNextEntry(zipEntry);
     byte[] bytes = new byte[1024];
     int length;

Reply via email to