feat(media): albums — one link for a season or a photo album; fix path traversal in media get

An album is a sealed file (shade.album/v1) listing grants, so the relay
cannot tell it from a film. `shade media put dir/` uploads every file and
the album (subdirectories nest, natural order); `media get` brings an
album back as a directory; /watch/ shows a grid with decrypted previews
and Back returns to the album without putting grants in history. Kotlin
reads albums (Albums.read) against a new shared vector.

Fixed: `media get` used the sealer-chosen meta.name as the output path.
Fixed a relay test race (flush() is sent, not received); the relay now
reports framesIn.

Verified: 64 TS tests x3, Kotlin 81/0, a 6-file album with a nested album
uploaded, browsed, played and downloaded back bit-identical.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-10-18 21:44:43 +02:00
parent e696d83283
commit 8c7300fa51
18 changed files with 726 additions and 44 deletions

View File

@@ -165,7 +165,8 @@ function toBytes(data: unknown): Uint8Array | null {
export interface LiveRelay {
app: Hono;
/** Channels currently held, for metrics and tests. */
stats(): { channels: number; viewers: number; backlogBytes: number };
/** `framesIn`: frames accepted from publishers since the relay started. */
stats(): { channels: number; viewers: number; backlogBytes: number; framesIn: number };
/** Drop idle channels now (also runs on a timer). */
sweep(): void;
stop(): void;
@@ -178,6 +179,7 @@ export function createLiveRelay(opts: LiveRelayOptions): LiveRelay {
const maxFrames = opts.maxBacklogFrames ?? 5000;
const highWater = opts.viewerHighWater ?? 8 * 1024 * 1024;
const idleMs = opts.idleRetentionMs ?? 10 * 60 * 1000;
let framesIn = 0;
const maxFrameBytes = opts.maxFrameBytes ?? 16 * 1024 * 1024 + 256;
const channels = new Map<string, Channel>();
const allowedOwners = opts.allowedOwners !== undefined ? new Set(opts.allowedOwners) : null;
@@ -284,6 +286,7 @@ export function createLiveRelay(opts: LiveRelayOptions): LiveRelay {
trim(ch);
}
if ((flags & FLAG_END) !== 0) ch.ended = true;
framesIn++;
for (const v of ch.viewers) deliver(v, copy, sticky, keyframe, ch.sawKeyframe);
return null;
}
@@ -441,7 +444,7 @@ export function createLiveRelay(opts: LiveRelayOptions): LiveRelay {
viewers += ch.viewers.size;
backlogBytes += ch.backlogBytes;
}
return { channels: channels.size, viewers, backlogBytes };
return { channels: channels.size, viewers, backlogBytes, framesIn };
},
sweep,
stop() {