Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
fix: bulk download all folders
Marc Seitz97270f019022
diff --git a/pages/api/links/download/bulk.ts b/pages/api/links/download/bulk.tsindex c8e42569..79e4caa8 100644--- a/pages/api/links/download/bulk.ts+++ b/pages/api/links/download/bulk.ts@@ -126,13 +126,47 @@ export default async function handle();// Helper function to add a file to the structure+ // const addFileToStructure = (+ // path: string,+ // fileName: string,+ // fileKey: string,+ // ) => {+ // const folderInfo = folderMap.get(path) || { name: "Root", id: null };+ // if (!folderStructure[path]) {+ // folderStructure[path] = {+ // name: folderInfo.name,+ // path: path,+ // files: [],+ // };+ // }+ // folderStructure[path].files.push({ name: fileName, key: fileKey });+ // fileKeys.push(fileKey);+ // };+const addFileToStructure = (path: string,fileName: string,fileKey: string,) => {- const folderInfo = folderMap.get(path) || { name: "Root", id: null };+ const pathParts = path.split("/").filter(Boolean);+ let currentPath = "";++ // Add folder information for each level of the path+ pathParts.forEach((part, index) => {+ currentPath += "/" + part;+ const folderInfo = folderMap.get(currentPath);+ if (!folderStructure[currentPath]) {+ folderStructure[currentPath] = {+ name: folderInfo ? folderInfo.name : part,+ path: currentPath,+ files: [],+ };+ }+ });++ // Add the file to the leaf folderif (!folderStructure[path]) {+ const folderInfo = folderMap.get(path) || { name: "Root", id: null };folderStructure[path] = {name: folderInfo.name,path: path,@@ -175,6 +209,11 @@ export default async function handle(doc.document.versions[0].file,),);++ // If the folder is empty, ensure it's still added to the structure+ if (folderDocs && folderDocs.length === 0) {+ addFileToStructure(folder.path, "", "");+ }});const client = getLambdaClient();