3D 리플레이: 리플레이 파일이 없으면 '리플레이 파일 없음'과 새로고침 버튼 (내려받은 뒤 누르면 다시 찾아 변환) · 오류 상태에도 새로고침 · 목 서버는 리플레이 파일이 없으면 404

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-31 03:30:39 +09:00
parent cfe5075f76
commit d0371fa0ac
4 changed files with 50 additions and 9 deletions

View File

@@ -347,7 +347,8 @@ async function handle(req, res) {
if ((m = p.match(/^\/api\/matches\/([^/]+)\/replay$/))) {
const mt = db.matches.find((x) => x.id === decodeURIComponent(m[1]));
if (!mt) return json(res, 404, { error: 'not_found' });
if (!mt.replayPath) return json(res, 404, { error: 'replay_not_found' });
// 파일을 지웠다가 다시 두면 "리플레이 없음 → 내려받고 새로고침" 을 흉내 낼 수 있다
if (!mt.replayPath || !fs.existsSync(mt.replayPath)) return json(res, 404, { error: 'replay_not_found' });
res.writeHead(200, { 'content-type': 'application/json' });
return fs.createReadStream(mt.replayPath).pipe(res);
}

View File

@@ -14,6 +14,8 @@ export function ReplayPanel({ m }: { m: MatchDetail }) {
const [replay, setReplay] = useState<ReplayFile | null>(null);
const [err, setErr] = useState<unknown>(null);
const [converting, setConverting] = useState(false);
// 새로고침을 누를 때마다 1씩 올려 리플레이를 다시 묻는다
const [reload, setReload] = useState(0);
useEffect(() => {
if (!open || replay) return;
let alive = true;
@@ -22,7 +24,7 @@ export function ReplayPanel({ m }: { m: MatchDetail }) {
// 처음 열면 게임 PC 가 리플레이를 변환한다 (보통 10초 안팎). 변환 중(202)이면 3초 뒤 다시 묻는다 (5분까지)
const ask = (tries: number) =>
api
.replay(m.id)
.replay(m.id, reload > 0)
.then((r) => {
if (!alive) return;
if ('status' in r && r.status === 'converting') {
@@ -46,12 +48,17 @@ export function ReplayPanel({ m }: { m: MatchDetail }) {
alive = false;
if (timer) clearTimeout(timer);
};
}, [open, m.id, replay]);
}, [open, m.id, replay, reload]);
const sync = useMemo(() => (replay ? computeSync(m, replay) : null), [m, replay]);
// replay_not_found: 앱이 리플레이를 못 찾음. 다른 404: 이 앱 버전에는 리플레이 기능이 아직 없음
const missing = err instanceof ApiError && err.status === 404 && err.code === 'replay_not_found';
const appTooOld = err instanceof ApiError && err.status === 404 && err.code === 'Not Found'; // Fastify 기본 404 (경로 없음)
const failed = err instanceof ApiError && err.status === 422 && err.code === 'replay_failed';
const refresh = (
<button className="mini-btn" onClick={() => setReload((n) => n + 1)}>
새로고침
</button>
);
return (
<Panel
className={`replay-panel${open ? ' open' : ''}`}
@@ -67,15 +74,31 @@ export function ReplayPanel({ m }: { m: MatchDetail }) {
발로란트에서 이 경기 리플레이를 내려받으면 선수 10명의 움직임을 3D로 보면서 그때 나눈 대화를 같이 들을 수 있습니다.
</div>
) : missing ? (
<div className="dim small">
이 경기 리플레이가 아직 없습니다. 발로란트 경력 탭에서 이 경기의 리플레이를 내려받으면 게임 PC 앱이 찾아서 변환합니다 (몇 초 걸림).
<div className="replay-msg">
<div>
<b>리플레이 파일 없음</b>
<div className="dim small">
게임 PC 에 이 경기의 리플레이 파일이 없습니다. 발로란트 경력 탭에서 이 경기의 리플레이를 내려받은 뒤 새로고침을 누르면 게임 PC 앱이 찾아서
변환합니다 (몇 초 걸림).
</div>
</div>
{refresh}
</div>
) : appTooOld ? (
<div className="dim small">지금 게임 PC 앱 버전은 아직 리플레이를 보내지 않습니다. 리플레이 자동 변환이 들어간 앱으로 업데이트하면 볼 수 있습니다.</div>
<div className="replay-msg">
<div className="dim small">지금 게임 PC 앱 버전은 아직 리플레이를 보내지 않습니다. 리플레이 자동 변환이 들어간 앱으로 업데이트하면 볼 수 있습니다.</div>
{refresh}
</div>
) : failed ? (
<div className="dim small">게임 PC 가 이 경기 리플레이를 변환하지 못했습니다. 발로란트 패치로 리플레이 형식이 바뀌었을 수 있습니다. ({(err as ApiError).detail ?? '이유 모름'})</div>
<div className="replay-msg">
<div className="dim small">게임 PC 가 이 경기 리플레이를 변환하지 못했습니다. 발로란트 패치로 리플레이 형식이 바뀌었을 수 있습니다. ({(err as ApiError).detail ?? '이유 모름'})</div>
{refresh}
</div>
) : err ? (
<div className="dim small">리플레이를 불러오지 못했습니다: {err instanceof Error ? err.message : String(err)}</div>
<div className="replay-msg">
<div className="dim small">리플레이를 불러오지 못했습니다: {err instanceof Error ? err.message : String(err)}</div>
{refresh}
</div>
) : !replay || !sync ? (
<Spinner label={converting ? '게임 PC 가 리플레이를 변환하는 중 (처음 한 번, 10초 안팎)' : '리플레이 불러오는 중'} />
) : (

View File

@@ -165,7 +165,9 @@ export const api = {
matches: (o: { game?: GameType; limit?: number; before?: number } = {}) => request<MatchSummary[]>(`/api/matches${qs(o)}`),
match: (id: string) => request<MatchDetail>(`/api/matches/${encodeURIComponent(id)}`),
/** 발로란트 리플레이(.vrf)에서 뽑은 재생 데이터. 없으면 404 replay_not_found, 게임 PC 가 변환 중이면 202 { status: 'converting' } */
replay: (id: string) => request<ReplayFile | { status: 'converting' }>(`/api/matches/${encodeURIComponent(id)}/replay`),
// fresh: 새로고침 때는 브라우저 캐시를 거치지 않는다 (방금 내려받은 리플레이가 보이게)
replay: (id: string, fresh = false) =>
request<ReplayFile | { status: 'converting' }>(`/api/matches/${encodeURIComponent(id)}/replay`, fresh ? { cache: 'no-cache' } : {}),
culpritMatches: (o: { game?: GameType; limit?: number } = {}) => request<CulpritMatchItem[]>(`/api/culprit/matches${qs(o)}`),
culpritMatch: (id: string) => request<CulpritMatchInfo>(`/api/culprit/matches/${encodeURIComponent(id)}`),
culpritBudget: () => request<CulpritBudget>('/api/culprit/budget'),

View File

@@ -3936,6 +3936,21 @@ button.match:hover {
}
/* ── 3D 리플레이 (components/ReplayViewer.tsx) ── */
.replay-msg {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.replay-msg b {
display: block;
margin-bottom: 2px;
color: #e6edf3;
font-size: 13px;
}
.replay-msg .mini-btn {
flex: none;
}
.replay-panel {
flex: none;
}