Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: download artifacts from unmerged-lane-id when applicable #6537

Merged
merged 2 commits into from
Oct 12, 2022
Merged
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
25 changes: 24 additions & 1 deletion src/consumer/component/sources/artifact-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,32 @@ export class ArtifactFiles {
const allHashes = this.refs.map((artifact) => artifact.ref.hash);
const scopeComponentsImporter = ScopeComponentsImporter.getInstance(scope);
const lane = await scope.getCurrentLaneObject();
const unmergedEntry = scope.objects.unmergedComponents.getEntry(id.name);
let errorFromUnmergedLaneScope: Error | undefined;
if (unmergedEntry?.laneId) {
try {
logger.debug(
`getVinylsAndImportIfMissing, trying to get artifacts for ${id.toString()} from unmerged-lane-id: ${unmergedEntry.laneId.toString()}`
);
await scopeComponentsImporter.importManyObjects({ [unmergedEntry.laneId.scope]: allHashes });
} catch (err: any) {
logger.debug(
`getVinylsAndImportIfMissing, unable to get artifacts for ${id.toString()} from ${unmergedEntry.laneId.toString()}`
);
errorFromUnmergedLaneScope = err;
}
}
const isIdOnLane = await scope.isIdOnLane(id, lane);
const scopeName = isIdOnLane ? (lane?.scope as string) : (id.scope as string);
await scopeComponentsImporter.importManyObjects({ [scopeName]: allHashes });
try {
await scopeComponentsImporter.importManyObjects({ [scopeName]: allHashes });
} catch (err) {
if (!unmergedEntry || errorFromUnmergedLaneScope) {
logger.error('failed fetching the following hashes', { id, isIdOnLane, scopeName, allHashes });
throw err;
}
// unmergedEntry is set, and it was able to fetch from the unmerged-lane-id scope. all is good.
}
const getOneArtifact = async (artifact: ArtifactRef) => {
const content = (await artifact.ref.load(scope.objects)) as Source;
if (!content) throw new ShowDoctorError(`failed loading file ${artifact.relativePath} from the model`);
Expand Down