Skip to content

Commit 8538907

Browse files
authored
Merge pull request #28 from sonicbaume/obf-update-zip
Update existing OBZ to retain images
2 parents 780f1f5 + 91a6347 commit 8538907

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/processors/obfProcessor.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ class ObfProcessor extends BaseProcessor {
714714
}
715715

716716
async saveFromTree(tree: AACTree, outputPath: string): Promise<void> {
717-
const { writeTextToPath, writeBinaryToPath } = this.options.fileAdapter;
717+
const { writeTextToPath, writeBinaryToPath, pathExists } = this.options.fileAdapter;
718718
if (outputPath.endsWith('.obf')) {
719719
// Save as single OBF JSON file
720720
const rootPage = tree.rootId ? tree.getPage(tree.rootId) : Object.values(tree.pages)[0];
@@ -734,8 +734,11 @@ class ObfProcessor extends BaseProcessor {
734734
data: new TextEncoder().encode(obfContent),
735735
};
736736
});
737-
//TODO update zip to retain images
738-
this.zipFile = await this.options.zipAdapter(undefined, this.options.fileAdapter);
737+
const fileExists = await pathExists(outputPath);
738+
this.zipFile = await this.options.zipAdapter(
739+
fileExists ? outputPath : undefined,
740+
this.options.fileAdapter
741+
);
739742
const zipData = await this.zipFile.writeFiles(files);
740743
await writeBinaryToPath(outputPath, zipData);
741744
}

0 commit comments

Comments
 (0)