Skip to content

Commit

Permalink
Allow placing the zip in the home folder, fixes apache#4393
Browse files Browse the repository at this point in the history
  • Loading branch information
hansva committed Oct 10, 2024
1 parent dd066da commit 7dd8014
Showing 1 changed file with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1073,14 +1073,17 @@ public void fileDialogBrowserProjectHome() {
public void menuProjectExport() {
HopGui hopGui = HopGui.getInstance();
Shell shell = hopGui.getShell();
IVariables variables = hopGui.getVariables();

// Resolve variables in filepath
String zipFilename =
BaseDialog.presentFileDialog(
true,
shell,
new String[] {"*.zip", "*.*"},
new String[] {"Zip files (*.zip)", "All Files (*.*)"},
true);
variables.resolve(
BaseDialog.presentFileDialog(
true,
shell,
new String[] {"*.zip", "*.*"},
new String[] {"Zip files (*.zip)", "All Files (*.*)"},
true));
if (zipFilename == null) {
return;
}
Expand All @@ -1104,7 +1107,6 @@ public void menuProjectExport() {
monitor.setTaskName(
BaseMessages.getString(PKG, "ProjectGuiPlugin.ZipDirectory.Taskname.Text"));
HashMap variablesMap = new HashMap<>();
IVariables variables = hopGui.getVariables();

for (String name : variables.getVariableNames()) {
if (!name.contains("java.")
Expand Down Expand Up @@ -1144,15 +1146,20 @@ public void menuProjectExport() {
String projectHomeFolder =
HopVfs.getFileObject(projectHome).getParent().getName().getURI();
zipFile(
projectDirectory, projectDirectory.getName().getURI(), zos, projectHomeFolder);
projectDirectory,
projectDirectory.getName().getURI(),
zos,
projectHomeFolder,
zipFilename);
zipFile(
HopVfs.getFileObject(
Const.HOP_CONFIG_FOLDER + Const.FILE_SEPARATOR + Const.HOP_CONFIG),
projectDirectory.getName().getBaseName()
+ Const.FILE_SEPARATOR
+ Const.HOP_CONFIG,
zos,
projectHomeFolder);
projectHomeFolder,
zipFilename);
zipString(
variablesJson, "variables.json", zos, projectDirectory.getName().getBaseName());
zipString(
Expand Down Expand Up @@ -1190,7 +1197,8 @@ public void zipFile(
FileObject fileToZip,
String filename,
ZipOutputStream zipOutputStream,
String projectHomeParent)
String projectHomeParent,
String zipFilename)
throws IOException {
if (fileToZip.isHidden()) {
return;
Expand All @@ -1206,11 +1214,15 @@ public void zipFile(
}
FileObject[] children = fileToZip.getChildren();
for (FileObject childFile : children) {
if (childFile.equals(zipFilename)) {
return;
}
zipFile(
childFile,
filename + "/" + childFile.getName().getBaseName(),
zipOutputStream,
projectHomeParent);
projectHomeParent,
zipFilename);
}
return;
}
Expand Down

0 comments on commit 7dd8014

Please sign in to comment.