Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(editor): log when export blob failed (#10287)

donteatfriedrice54b75151675b
diff --git a/blocksuite/blocks/src/_common/transformers/zip.ts b/blocksuite/blocks/src/_common/transformers/zip.ts
index 97a1f24043..dd5fca07ad 100644
--- a/blocksuite/blocks/src/_common/transformers/zip.ts
+++ b/blocksuite/blocks/src/_common/transformers/zip.ts
@@ -35,17 +35,30 @@ async function exportDocs(collection: Workspace, docs: Store[]) {
const pathBlobIdMap = job.assetsManager.getPathBlobIdMap();
const assetsMap = job.assets;
- await Promise.all(
+ // Add blobs to assets folder, if failed, log the error and continue
+ const results = 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);
+ try {
+ 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);
+ return { success: true, blobId };
+ }
+ return { success: false, blobId, error: 'Blob not found' };
+ } catch (error) {
+ console.error(`Failed to process blob: ${blobId}`, error);
+ return { success: false, blobId, error };
}
})
);
+ const failures = results.filter(r => !r.success);
+ if (failures.length > 0) {
+ console.warn(`Failed to process ${failures.length} blobs:`, failures);
+ }
+
const downloadBlob = await zip.generate();
return download(downloadBlob, `${collection.id}.bs.zip`);
}