Skip to content

Commit 5e09485

Browse files
committed
fix(FileManager): exporting folder as zip was not working with subfolders
1 parent e3bb575 commit 5e09485

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/components/FileManager/file-manager.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@ export function isValidName(name: string) {
1818
return true;
1919
}
2020

21-
export async function getFolderZip(path: string) {
21+
export async function getFolderZip(folderPath: string) {
2222
const zip = new JSZip();
23-
const files = await readdir(path, { withFileTypes: true, recursive: true });
23+
const files = await readdir(folderPath, {
24+
withFileTypes: true,
25+
recursive: true,
26+
});
2427
for (const file of files) {
2528
const path = resolve(file.parentPath, file.name);
2629
if (file.isDirectory()) {
2730
zip.folder(path);
2831
} else if (file.isFile()) {
29-
const content = await readFile(path);
32+
const absolutePath = resolve(folderPath, file.parentPath, file.name);
33+
const content = await readFile(absolutePath);
3034
zip.file(path, content);
3135
}
3236
}

0 commit comments

Comments
 (0)