fix(cli): check says how many browser-playable copies are done while it makes them (#6712)

This commit is contained in:
Miguel Ángel
2026-10-29 05:02:58 +00:00
committed by GitHub
parent fa9acbd739
commit 2f8c4b1daf
2 changed files with 12 additions and 5 deletions
+5 -3
View File
@@ -1502,7 +1502,7 @@ describe("preResolveHostileMediaProxies", () => {
await pending;
expect(errorSpy.mock.calls.map(([line]) => line)).toContain(
"[hyperframes] browser-playable copy of clip.mov: 25% (10s so far)",
"[hyperframes] making browser-playable copies: 0 of 1 done. clip.mov: 25% (10s so far)",
);
} finally {
mocks.proxyProgress.feed = undefined;
@@ -1540,8 +1540,10 @@ describe("preResolveHostileMediaProxies", () => {
await pending;
const lines = errorSpy.mock.calls.map(([line]) => String(line));
expect(lines).toContain("[hyperframes] browser-playable copy of b.mov: 25% (10s so far)");
expect(lines.some((line) => line.includes("copy of a.mov"))).toBe(false);
expect(lines).toContain(
"[hyperframes] making browser-playable copies: 1 of 2 done. b.mov: 25% (10s so far)",
);
expect(lines.some((line) => line.includes(" a.mov: "))).toBe(false);
} finally {
mocks.proxyProgress.feed = undefined;
vi.useRealTimers();
+7 -2
View File
@@ -165,6 +165,8 @@ function startCopyHeartbeat(
} {
const startedAt = Date.now();
const latest = new Map<number, ProxyProgress>();
const total = cached.filter((isCached) => !isCached).length;
let finished = 0;
const timer = setInterval(() => {
for (const [index, { doneSeconds, totalSeconds }] of latest) {
if (cached[index]) continue;
@@ -172,14 +174,17 @@ function startCopyHeartbeat(
? `${Math.min(100, Math.floor((doneSeconds / totalSeconds) * 100))}%`
: "";
console.error(
`[hyperframes] browser-playable copy of ${sources[index]!.file}: ${done || `${Math.floor(doneSeconds)}s done`} (${elapsedText(Date.now() - startedAt)} so far)`,
`[hyperframes] making browser-playable copies: ${finished} of ${total} done. ${sources[index]!.file}: ${done || `${Math.floor(doneSeconds)}s done`} (${elapsedText(Date.now() - startedAt)} so far)`,
);
}
}, COPY_HEARTBEAT_MS);
timer.unref();
return {
progress: (index, progress) => void latest.set(index, progress),
settled: (index) => void latest.delete(index),
settled: (index) => {
latest.delete(index);
if (!cached[index]) finished += 1;
},
stop: () => clearInterval(timer),
};
}