mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-29 08:09:52 +08:00
fix(editor): log when export blob failed (#10287)
This commit is contained in:
@@ -35,17 +35,30 @@ async function exportDocs(collection: Workspace, docs: Store[]) {
|
|||||||
const pathBlobIdMap = job.assetsManager.getPathBlobIdMap();
|
const pathBlobIdMap = job.assetsManager.getPathBlobIdMap();
|
||||||
const assetsMap = job.assets;
|
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 => {
|
Array.from(pathBlobIdMap.values()).map(async blobId => {
|
||||||
await job.assetsManager.readFromBlob(blobId);
|
try {
|
||||||
const ext = getAssetName(assetsMap, blobId).split('.').at(-1);
|
await job.assetsManager.readFromBlob(blobId);
|
||||||
const blob = assetsMap.get(blobId);
|
const ext = getAssetName(assetsMap, blobId).split('.').at(-1);
|
||||||
if (blob) {
|
const blob = assetsMap.get(blobId);
|
||||||
await assets.file(`${blobId}.${ext}`, blob);
|
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();
|
const downloadBlob = await zip.generate();
|
||||||
return download(downloadBlob, `${collection.id}.bs.zip`);
|
return download(downloadBlob, `${collection.id}.bs.zip`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user