[rooms] fix cloud variables

This commit is contained in:
Devin Zuczek
2026-10-03 21:53:23 -04:00
parent ec423b2eb9
commit f7167358d8
6 changed files with 74 additions and 21 deletions
+7 -2
View File
@@ -37,7 +37,12 @@ import type { App } from './context'
*
* RoomSave (1) lands under `room/` (not `roomsave/`) so the `cdn` worker's
* `GET /room/:dataBlob` route serves the blob back — both bind the same
* `recflare-cdn` bucket, so the key prefixes must match.
* `recflare-cdn` bucket, so the key prefixes must match. RoomMetadata (6) — the
* room-level blob a room save posts as `RoomData`, which the room then names as its
* `DataBlob` — lands under `room/` too: the client fetches it from the same
* `/room/<name>` path it fetches the scene from. It once went under `roommetadata/`,
* where nothing ever asked for it. The two never collide — every upload is named by
* a fresh GUID under the day's folder.
*/
const UPLOAD_SUBFOLDER: Record<number, string> = {
1: 'room',
@@ -45,7 +50,7 @@ const UPLOAD_SUBFOLDER: Record<number, string> = {
3: 'image',
4: 'video',
5: 'invention',
6: 'roommetadata',
6: 'room',
}
/** Resolve the storage subfolder for a posted FileType, or `undefined` when unknown. */
@@ -63,7 +63,7 @@ it('POST /upload 401s without a token', async () => {
expect(res.status).toBe(401)
})
it('POST /upload stores a RoomMetadata (FileType 6) file under roommetadata/ and returns its name', async () => {
it('POST /upload stores a RoomMetadata (FileType 6) file under room/ and returns its name', async () => {
// Mirrors the client's multipart upload: FileType=6, File=<binary>.
const bytes = new Uint8Array([0x10, 0x02, 0x1a, 0x00])
const res = await SELF.fetch(`${ORIGIN}/upload`, {
@@ -77,8 +77,9 @@ it('POST /upload stores a RoomMetadata (FileType 6) file under roommetadata/ and
/^\d{4}-\d{2}-\d{2}\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
)
// The bytes are persisted in the shared CDN bucket under the type subfolder.
const stored = await env.CDN_ASSETS.get(`roommetadata/${filename}`)
// The bytes are persisted in the shared CDN bucket under `room/`, the same folder as a
// scene blob: the client downloads the room's `DataBlob` from the cdn's `/room/<name>`.
const stored = await env.CDN_ASSETS.get(`room/${filename}`)
expect(stored).not.toBeNull()
expect(new Uint8Array(await stored!.arrayBuffer())).toEqual(bytes)
})