fix(editor): missing resource files in exported snapshot zip (#9450)

Closes: [BS-2280](https://linear.app/affine-design/issue/BS-2280/导出-zip-snapshot-丢失-blob)
This commit is contained in:
Saul-Mirone
2024-12-31 05:13:43 +00:00
parent 7aba836dbe
commit 0f03c3fc5e
4 changed files with 48 additions and 8 deletions

View File

@@ -23,13 +23,19 @@ async function exportDocs(collection: DocCollection, docs: Doc[]) {
);
const assets = zip.folder('assets');
const pathBlobIdMap = job.assetsManager.getPathBlobIdMap();
const assetsMap = job.assets;
for (const [id, blob] of assetsMap) {
const ext = getAssetName(assetsMap, id).split('.').at(-1);
const name = `${id}.${ext}`;
await assets.file(name, blob);
}
await Promise.all(
Array.from(pathBlobIdMap.values()).map(async blobId => {
await job.assetsManager.readFromBlob(blobId);
const ext = getAssetName(assetsMap, blobId).split('.').at(-1);
const blob = assetsMap.get(blobId);
if (blob) {
await assets.file(`${blobId}.${ext}`, blob);
}
})
);
const downloadBlob = await zip.generate();
return download(downloadBlob, `${collection.id}.bs.zip`);