fix: load missing assets when retrieving backup (#3192)
This commit is contained in:
@ -290,8 +290,17 @@ export function retrieveLocalBackup(collection: Collection, slug: string) {
|
|||||||
if (entry) {
|
if (entry) {
|
||||||
// load assets from backup
|
// load assets from backup
|
||||||
const mediaFiles = entry.mediaFiles || [];
|
const mediaFiles = entry.mediaFiles || [];
|
||||||
const assetProxies: AssetProxy[] = mediaFiles.map(file =>
|
const assetProxies: AssetProxy[] = await Promise.all(
|
||||||
createAssetProxy({ path: file.path, file: file.file, url: file.url }),
|
mediaFiles.map(file => {
|
||||||
|
if (file.file || file.url) {
|
||||||
|
return createAssetProxy({ path: file.path, file: file.file, url: file.url });
|
||||||
|
} else {
|
||||||
|
return getAsset({ collection, entry: fromJS(entry), path: file.path })(
|
||||||
|
dispatch,
|
||||||
|
getState,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
dispatch(addAssets(assetProxies));
|
dispatch(addAssets(assetProxies));
|
||||||
|
|
||||||
|
@ -450,7 +450,8 @@ export class Backend {
|
|||||||
// make sure to serialize the file
|
// make sure to serialize the file
|
||||||
if (file.url?.startsWith('blob:')) {
|
if (file.url?.startsWith('blob:')) {
|
||||||
const blob = await fetch(file.url as string).then(res => res.blob());
|
const blob = await fetch(file.url as string).then(res => res.blob());
|
||||||
return { ...file, file: new File([blob], file.name) };
|
const options = file.name.match(/.svg$/) ? { type: 'image/svg+xml' } : {};
|
||||||
|
return { ...file, file: new File([blob], file.name, options) };
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
}),
|
}),
|
||||||
|
Reference in New Issue
Block a user