From 91a63477bdbe705ba528c822ecf7170aa2db675a Mon Sep 17 00:00:00 2001 From: Chris Baume Date: Sun, 22 Feb 2026 21:14:48 +0000 Subject: [PATCH] Overwrite obz to retain images --- src/processors/obfProcessor.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/processors/obfProcessor.ts b/src/processors/obfProcessor.ts index f5a1268..21beb73 100644 --- a/src/processors/obfProcessor.ts +++ b/src/processors/obfProcessor.ts @@ -714,7 +714,7 @@ class ObfProcessor extends BaseProcessor { } async saveFromTree(tree: AACTree, outputPath: string): Promise { - const { writeTextToPath, writeBinaryToPath } = this.options.fileAdapter; + const { writeTextToPath, writeBinaryToPath, pathExists } = this.options.fileAdapter; if (outputPath.endsWith('.obf')) { // Save as single OBF JSON file const rootPage = tree.rootId ? tree.getPage(tree.rootId) : Object.values(tree.pages)[0]; @@ -734,8 +734,11 @@ class ObfProcessor extends BaseProcessor { data: new TextEncoder().encode(obfContent), }; }); - //TODO update zip to retain images - this.zipFile = await this.options.zipAdapter(undefined, this.options.fileAdapter); + const fileExists = await pathExists(outputPath); + this.zipFile = await this.options.zipAdapter( + fileExists ? outputPath : undefined, + this.options.fileAdapter + ); const zipData = await this.zipFile.writeFiles(files); await writeBinaryToPath(outputPath, zipData); }