diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 1dd26a5..d430727 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,9 +3,7 @@
-
-
-
+
@@ -51,7 +49,7 @@
1781169139290
-
+
@@ -101,7 +99,23 @@
1781261986439
-
+
+
+ 1781263980882
+
+
+
+ 1781263980882
+
+
+
+ 1781264183729
+
+
+
+ 1781264183729
+
+
@@ -117,7 +131,9 @@
-
+
+
+
diff --git a/src/lib/zip-processing.ts b/src/lib/zip-processing.ts
index d1e4768..8ff3c8d 100644
--- a/src/lib/zip-processing.ts
+++ b/src/lib/zip-processing.ts
@@ -56,6 +56,8 @@ const isPdf = (path: string) => getExtension(path) === ".pdf";
const isImage = (path: string) => IMAGE_EXTENSIONS.has(getExtension(path));
+const isZipArchive = (path: string) => getExtension(path) === ".zip";
+
const normalizeKey = (value: string) => value.replaceAll("\\", "/").toLowerCase().trim();
const isMacMetadataEntry = (path: string) => {
@@ -188,11 +190,10 @@ const orderAttachmentsByDocumentNames = (attachments: ZipAttachment[], documentN
return orderedAttachments;
};
-export const extractZipArchive = async (file: File): Promise => {
- const archiveBytes = new Uint8Array(await file.arrayBuffer());
+const extractZipEntries = async (archiveBytes: Uint8Array, fallbackName: string): Promise => {
const files = await unzipArchive(archiveBytes);
-
const attachments: ZipAttachment[] = [];
+ const nestedArchives: ProcessedZipArchive[] = [];
let xjustizNachrichtXml: Uint8Array | null = null;
for (const [path, data] of Object.entries(files)) {
@@ -207,6 +208,12 @@ export const extractZipArchive = async (file: File): Promise 0) {
+ archives.push({
+ name: archiveName,
+ attachments: orderedAttachments,
+ });
+ }
+
+ return [...archives, ...nestedArchives];
+};
+
+export const extractZipArchives = async (file: File): Promise => {
+ const archiveBytes = new Uint8Array(await file.arrayBuffer());
+
+ return extractZipEntries(archiveBytes, file.name);
};
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index 9e52527..42c6017 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -3,7 +3,7 @@
import Card from "$lib/components/Card.svelte";
import ProcessedZipArchiveEditor from "$lib/components/ProcessedZipArchiveEditor.svelte";
import ZipDropzone from "$lib/components/ZipDropzone.svelte";
- import { extractZipArchive, type ProcessedZipArchive } from "$lib/zip-processing";
+ import { extractZipArchives, type ProcessedZipArchive } from "$lib/zip-processing";
const THUMBNAIL_WIDTH_STORAGE_KEY = "thumbnailWidth";
@@ -49,8 +49,8 @@
pendingZipCount += 1;
try {
- const processedZipArchive = await extractZipArchive(file);
- processedZipFiles = [...processedZipFiles, processedZipArchive];
+ const processedZipArchives = await extractZipArchives(file);
+ processedZipFiles = [...processedZipFiles, ...processedZipArchives];
} catch (error) {
console.error(`Failed to process ${file.name}`, error);
} finally {