mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00: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 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`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user