Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions packages/contentstack-asset-management/src/import/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,6 @@ export default class ImportWorkspace extends CSAssetsImportAdapter {
assetsImporter.setProcessName(spaceProcessName);
}

// Map source default space → existing target default space (cross-org migration).
// The caller supplies the uid of the pre-existing target default space; we upload
// source assets into it instead of creating a new space.
if (isDefault && targetDefaultSpaceUid) {
const newSpaceUid = targetDefaultSpaceUid;
const resolvedWorkspaceUid = targetDefaultWorkspaceUid ?? workspaceUid;
log.info(
`Source default space "${oldSpaceUid}" mapped to existing target default space "${newSpaceUid}".`,
this.importContext.context,
);
const { uidMap, urlMap } = await assetsImporter.start(newSpaceUid, spaceDir);
return { oldSpaceUid, newSpaceUid, workspaceUid: resolvedWorkspaceUid, isDefault: true, uidMap, urlMap };
}

// Reuse: target org already has a space with the same uid as the export directory.
if (existingSpaceUids.has(oldSpaceUid)) {
log.info(
Expand All @@ -100,6 +86,20 @@ export default class ImportWorkspace extends CSAssetsImportAdapter {
urlMap,
};
}

// Map source default space → existing target default space (cross-org migration).
// The caller supplies the uid of the pre-existing target default space; we upload
// source assets into it instead of creating a new space.
if (isDefault && targetDefaultSpaceUid) {
const newSpaceUid = targetDefaultSpaceUid;
const resolvedWorkspaceUid = targetDefaultWorkspaceUid ?? workspaceUid;
log.info(
`Source default space "${oldSpaceUid}" mapped to existing target default space "${newSpaceUid}".`,
this.importContext.context,
);
const { uidMap, urlMap } = await assetsImporter.start(newSpaceUid, spaceDir);
return { oldSpaceUid, newSpaceUid, workspaceUid: resolvedWorkspaceUid, isDefault: true, uidMap, urlMap };
}

// Create new space with exact exported title
log.debug(`Creating space "${exportedTitle}" (old uid: ${oldSpaceUid})`, this.importContext.context);
Expand Down
Loading