Fix sha256sum generation

Because we checksum when bottling, they have the bottle file name. We need to upload data to the binary store that has the binary store key name.
This commit is contained in:
Jacob Heider 2022-09-07 17:16:01 -04:00
parent 43037362d6
commit 24d40b7c4f

View file

@ -68,9 +68,9 @@ for (const rq of bottles) {
console.log({ key });
//FIXME stream it to S3
const [basename, dirname] = (split => [split.pop(), split.join("/")])(key.split("/"))
const bottle_contents = await Deno.readFile(bottle.string)
const checksum_contents = await Deno.readFile(checksum.string)
const dirname = key.split("/").slice(0, -1).join("/")
const checksum_contents = fixup_checksum(await Deno.readFile(checksum.string), basename!)
const versions = await get_versions(pkg)
await bucket.putObject(key, bottle_contents)
@ -100,3 +100,9 @@ async function get_versions(pkg: Package): Promise<SemVer[]> {
// have to add pkg.version as put and get are not atomic
return [...new Set([...got, pkg.version])].sort()
}
// Somewhat hacky. We call the bottle on thing locally, and another on the server.
function fixup_checksum(data: Uint8Array, new_file_name: string) {
const checksum = new TextDecoder().decode(data).split(" ")[0]
return new TextEncoder().encode(`${checksum} ${new_file_name}`)
}