deduplicate subjects before adding to statement (#180)

Signed-off-by: Brian DeHamer <bdehamer@github.com>
This commit is contained in:
Brian DeHamer
2024-12-06 07:14:14 -08:00
committed by GitHub
parent 4cd38b497a
commit 65e34a8aa7
5 changed files with 40 additions and 5 deletions
Generated Vendored
+4 -1
View File
@@ -71205,7 +71205,10 @@ const getSubjectFromPath = async (subjectPath, subjectName) => {
for (const file of files) {
const name = subjectName || path_1.default.parse(file).base;
const digest = await digestFile(DIGEST_ALGORITHM, file);
digestedSubjects.push({ name, digest: { [DIGEST_ALGORITHM]: digest } });
// Only add the subject if it is not already in the list
if (!digestedSubjects.some(s => s.name === name && s.digest[DIGEST_ALGORITHM] === digest)) {
digestedSubjects.push({ name, digest: { [DIGEST_ALGORITHM]: digest } });
}
}
if (digestedSubjects.length === 0) {
throw new Error(`Could not find subject at path ${subjectPath}`);