Skip to content

Commit fedefe0

Browse files
committed
Allow importing assets with elements (by ignoring the elements)
1 parent 8837b59 commit fedefe0

File tree

2 files changed

+8
-3
lines changed
  • src
    • commands/environment/backupRestore
    • modules/backupRestore/backupRestoreEntities/entities

2 files changed

+8
-3
lines changed

src/commands/environment/backupRestore/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ await restoreEnvironment(params);
233233

234234
- **Asset Size Limit**: The Management API accepts only assets smaller than 100 MB. If your backup file contains assets larger than that (they can be uploaded through the UI), the tool won't be able to import them.
235235
- **Asset Quality**: Assets fetched by the tool may be compressed and metadata can be missing. You may find more information about asset compression in the [quality parameter](https://kontent.ai/learn/docs/apis/image-transformation-api#a-quality-parameter) documentation.
236+
- **Asset Elements**: It is not possible to restore assets with elements at the moment. Assets will be imported without their elements. If you need the elements, you can adjust the asset type manually in the UI and import the elements using the Management API after the assets and taxonomies are restored.
236237

237238
### Performance
238239

src/modules/backupRestore/backupRestoreEntities/entities/assets.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type archiver from "archiver";
44
import chalk from "chalk";
55
import type { StreamZipAsync } from "node-stream-zip";
66

7-
import { type LogOptions, logInfo } from "../../../../log.js";
7+
import { type LogOptions, logInfo, logWarning } from "../../../../log.js";
88
import { serially } from "../../../../utils/requests.js";
99
import type { ReplaceReferences } from "../../../../utils/types.js";
1010
import { getRequired } from "../../utils/utils.js";
@@ -36,10 +36,13 @@ export const assetsEntity = {
3636
importEntities: async (client, { entities: fileAssets, context, logOptions, zip }) => {
3737
const fileAssetsWithElements = fileAssets.filter((a) => !!a.elements.length);
3838
if (fileAssetsWithElements.length) {
39-
throw new Error(
40-
`It is not possible to restore assets with elements at the moment. Assets that contain elements are: ${fileAssetsWithElements
39+
logWarning(
40+
logOptions,
41+
"verbose",
42+
`It is not possible to restore assets with elements at the moment. The following assets will be imported without their elements: ${fileAssetsWithElements
4143
.map((a) => a.id)
4244
.join(", ")}.`,
45+
"If you want the elements, import them using a management API after the assets are imported.",
4346
);
4447
}
4548

@@ -130,6 +133,7 @@ const createImportAssetFetcher =
130133
.withData(() => ({
131134
title: fileAsset.title,
132135
codename: fileAsset.codename,
136+
elements: [], // Elements are currently not supported
133137
...(folderId ? { folder: { id: folderId } } : undefined),
134138
file_reference: fileRef,
135139
...(collectionId ? { collection: { reference: { id: collectionId } } } : undefined),

0 commit comments

Comments
 (0)