Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
donmccurdy committed Oct 8, 2024
1 parent cc86244 commit 58047f3
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions packages/core/src/io/writer-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,24 @@ export class WriterContext {
const resources = this.jsonDoc.resources;

// https://github.com/KhronosGroup/glTF/issues/2446
if (uri in resources && data !== resources[uri]) {
const msg = `Resource URI "${uri}" already assigned to different data.`;
if (throwOnConflict) {
throw new Error(msg);
} else {
this.logger.warn(msg);
}
if (!(uri in resources)) {
resources[uri] = data;
return;
}

if (uri in resources) {
if (data === resources[uri]) {
this.logger.warn(`Duplicate resource URI, "${uri}".`);
return;
}

resources[uri] = data;
const conflictMessage = `Resource URI "${uri}" already assigned to different data.`;

if (!throwOnConflict) {
this.logger.warn(conflictMessage);
return;
}

throw new Error(conflictMessage);
}

/**
Expand Down

0 comments on commit 58047f3

Please sign in to comment.