Skip to content

Commit

Permalink
fix: [BUG] - Download selected documents / folders : Zip creation iss…
Browse files Browse the repository at this point in the history
…ue and empty zip - EXO-72976 (#1271) (#1274)
  • Loading branch information
mkrout authored Jul 11, 2024
1 parent 6a7ec99 commit cc3fad9
Showing 1 changed file with 3 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ public static void createFile(Node node,
Node jrcNode = node.getNode("jcr:content");
InputStream inputStream = jrcNode.getProperty("jcr:data").getStream();
String path = "";
String nodePath = getPath(node);
String nodePath = node.getPath();
if (StringUtils.isNotEmpty(symlinkPath) || StringUtils.isNotEmpty(sourcePath)) {
nodePath = symlinkPath + nodePath.replace(sourcePath, "");
}
Expand All @@ -885,7 +885,7 @@ public static void createTempFilesAndFolders(Node node,
return;
}
if (JCRDocumentsUtil.isFolder(node)) {
String nodePath = getPath(node);
String nodePath = node.getPath();
if (StringUtils.isNotEmpty(symlinkPath) || StringUtils.isNotEmpty(sourcePath)) {
nodePath = symlinkPath + nodePath.replace(sourcePath, "");
}
Expand All @@ -901,32 +901,13 @@ public static void createTempFilesAndFolders(Node node,
String sourceID = node.getProperty(NodeTypeConstants.EXO_SYMLINK_UUID).getString();
Node sourceNode = JCRDocumentsUtil.getNodeByIdentifier(node.getSession(), sourceID);
if (sourceNode != null) {
createTempFilesAndFolders(sourceNode, getPath(node), getPath(sourceNode), tempFolderPath, parentPath);
createTempFilesAndFolders(sourceNode, node.getPath(), sourceNode.getPath(), tempFolderPath, parentPath);
}
} else {
createFile(node, symlinkPath, sourcePath, tempFolderPath, parentPath);
}
}
}

static String getPath(Node node) {
Node parent = node;
LinkedList<String> parents = new LinkedList<String>();
while (parent != null) {
try {
if (parent.hasProperty(NodeTypeConstants.EXO_TITLE)) {
parents.addFirst(Utils.getStringProperty(parent, NodeTypeConstants.EXO_TITLE));
} else {
parents.addFirst(parent.getName());
}
parent = parent.getParent();
} catch (RepositoryException e) {
parent = null;
}
}
return String.join("/", parents);
}

public static void cleanFiles(File file) {
File[] files = file.listFiles();
if (files != null) {
Expand Down

0 comments on commit cc3fad9

Please sign in to comment.