Skip to content

Commit

Permalink
Fix database write for artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
FyreByrd committed Oct 18, 2024
1 parent eb3e89e commit c311ec3
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,22 @@ export class Check extends ScriptoriaJobExecutor<BullMQ.ScriptoriaJobType.Build_
if (response.error) {
job.log(response.error);
}
let latestArtifactDate = new Date(0);
await DatabaseWrites.productArtifacts.createMany({
data: await Promise.all(
Object.entries(response.artifacts).map(async ([type, url]) => {
const res = await fetch(url, { method: 'HEAD' });
const timestamp = new Date();
const lastModified = new Date(res.headers.get('Last-Modified'));
if (lastModified > latestArtifactDate) {
latestArtifactDate = lastModified;
}
return {
ProductId: job.data.productId,
ProductBuildId: job.data.productBuildId,
ArtifactType: type,
Url: url,
ContentType: res.headers.get('Content-Type'),
LastModified: new Date(res.headers.get('Last-Modified')),
FileSize:
res.headers.get('Content-Type') !== 'text/html'
? parseInt(res.headers.get('Content-Length'))
Expand All @@ -124,6 +128,9 @@ export class Check extends ScriptoriaJobExecutor<BullMQ.ScriptoriaJobType.Build_
})
)
});
await DatabaseWrites.products.update(job.data.productId, {
DateBuilt: latestArtifactDate
})
job.updateProgress(80);
await DatabaseWrites.productBuilds.update({
where: {
Expand Down

0 comments on commit c311ec3

Please sign in to comment.