Skip to content

Commit

Permalink
feat(tools): store actual bsp files for maps created by seed script
Browse files Browse the repository at this point in the history
  • Loading branch information
tsa96 committed Apr 5, 2024
1 parent 66ab907 commit d06756d
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions libs/db/src/scripts/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,6 @@ prismaWrapper(async (prisma: PrismaClient) => {
};

const versions = arrayFrom(randRange(vars.submissionVersions), (i) => ({
// TODO: We'd have to upload the same BSP 50 or so times
// for submissions here, since submissions use the UUID
// of this entry. If we really want to test BSP downloads
// for map submission ingame, copy 'maps/dev_flatgrid' to
// `submissions/${uuid of each submission version}.bsp`
versionNum: i + 1,
hash: mapHash,
hasVmf: false, // Could add a VMF if we really want but leaving for now
Expand Down Expand Up @@ -638,7 +633,16 @@ prismaWrapper(async (prisma: PrismaClient) => {
submission: { include: { versions: true } },
reviews: { include: { comments: true } }
}
})
}),
status === MapStatus.APPROVED
? s3.send(
new PutObjectCommand({
Bucket: s3BucketName,
Key: approvedBspPath(name),
Body: mapBuffer
})
)
: Promise.resolve()
);

const lastVersion = map.submission.versions.at(-1);
Expand All @@ -647,6 +651,14 @@ prismaWrapper(async (prisma: PrismaClient) => {
data: { currentVersion: { connect: { id: lastVersion.id } } }
});

await s3.send(
new PutObjectCommand({
Bucket: s3BucketName,
Key: submissionBspPath(lastVersion.id),
Body: mapBuffer
})
);

if ([MapStatus.APPROVED, MapStatus.DISABLED].includes(map.status))
await prisma.mMap.update({
where: { id: map.id },
Expand Down

0 comments on commit d06756d

Please sign in to comment.