6 Commits

Author SHA1 Message Date
542f759585 chore: remove stray 0-byte garbage file from repo root
Accidentally tracked by the previous commit's git add -A. Untracked
artifact from shell-command mangling in an earlier smoke test, not
part of any feature.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 16:35:30 +09:00
3248d096e4 server-youtube: add POSIX zipapp fallback when native bundled binary won't run
If the native yt-dlp_linux/yt-dlp_macos binary fails to execute (glibc
mismatch, musl libc, wrong arch) AND no system yt-dlp is on PATH, fall
back to downloading the universal Python zipapp ('yt-dlp', ~3MB) and
running it via shebang. Requires python3 on PATH, which is standard on
modern Linux servers. Also: rewrite stale Windows-flavored install-path
comments to reflect actual cross-platform behavior.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 16:35:11 +09:00
8c9dc88e8b server-youtube: strip Zone.Identifier ADS on Windows after download
NTFS marks files downloaded over HTTP with a Zone.Identifier alternate
data stream, which SmartScreen/Attachment Manager can use to block
execution of yt-dlp.exe. Remove the ADS best-effort after each
download to reduce one likely cause of "execution verification failed"
in the user-reported failure.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 16:29:27 +09:00
b769f453a3 server-youtube: diagnostic detail + PATH fallback when bundled yt-dlp won't run
probeVersion() now captures stderr/exit-code/signal/spawn-error instead of
returning a bare boolean, and ensureYtDlp() tries the bundled binary first,
falls back to `yt-dlp(.exe)` on PATH if the bundled one won't execute (AV
block, missing libc symbol, broken download), and only then re-downloads.
The final user-facing error includes the per-attempt diagnostics so we can
actually see WHY verification failed instead of the opaque
"yt-dlp 다운로드는 됐지만 실행 검증에 실패했습니다." message.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 16:24:54 +09:00
5c13648f63 rp-pack: fail-fast on base track/painting collision (was: silent skip)
Reviewer correctly flagged that the previous skip-on-collision
behavior silently drops new quiz tracks when the base resourcepack
already has the same track_NN key. That makes the install LOOK
successful but breaks the quiz at runtime (datapack references the
missing track).

The new behavior throws a clear error explaining which key collided
and what the user must do (remove the conflicting base entry, or
use a different base). The base assets are still preserved (we
never overwrite); we just refuse to build a broken pack.

Removed the now-unused skip-summary log keys.
2026-05-23 17:26:41 +09:00
9efd4a696a rp-pack: never overwrite base resourcepack sounds/paintings (v0.3.5)
If the base resourcepack already has audio files under
assets/musicquiz/sounds/ or entries in assets/musicquiz/sounds.json,
the build now PRESERVES them and skips any new track that would
collide. Same policy for painting textures: existing cover_*.png
in the base are not overwritten by new ones.

Per-track collision is logged so the user can see exactly what was
preserved and what was skipped. Summary counts (added / skipped)
are also logged.

Requested by 사금향: "기존에 있는걸 삭제하거나 이상하게 엎어쓰지
말것" — preserve base assets unconditionally.
2026-05-23 17:18:46 +09:00
5 changed files with 156 additions and 50 deletions

View File

@@ -106,6 +106,8 @@
"packFormatFallback": "pack_format = {{format}} (mcVersion \"{{version}}\" 매칭 실패, 최신 폴백)", "packFormatFallback": "pack_format = {{format}} (mcVersion \"{{version}}\" 매칭 실패, 최신 폴백)",
"packFormatRange": "호환 범위 선언: pack_format {{min}} ~ {{max}} (supported_formats / min_format / max_format 모두 기록)", "packFormatRange": "호환 범위 선언: pack_format {{min}} ~ {{max}} (supported_formats / min_format / max_format 모두 기록)",
"soundsMerged": "기존 sounds.json 병합 ({{count}}개 항목)", "soundsMerged": "기존 sounds.json 병합 ({{count}}개 항목)",
"tracksAdded": "음악 트랙 추가됨: {{count}}곡",
"paintingsAdded": "사진 텍스처 추가됨: {{count}}장",
"ytdlpLine": "yt-dlp> {{line}}" "ytdlpLine": "yt-dlp> {{line}}"
}, },
"progress": { "progress": {
@@ -139,6 +141,8 @@
"ytdlpInstallFailed": "yt-dlp.exe 자동 설치 실패: {{message}}", "ytdlpInstallFailed": "yt-dlp.exe 자동 설치 실패: {{message}}",
"ffmpegNotInZip": "zip 내부에서 ffmpeg.exe 를 찾을 수 없습니다.", "ffmpegNotInZip": "zip 내부에서 ffmpeg.exe 를 찾을 수 없습니다.",
"ffmpegVerifyFailed": "ffmpeg.exe 다운로드는 됐지만 실행 검증에 실패했습니다.", "ffmpegVerifyFailed": "ffmpeg.exe 다운로드는 됐지만 실행 검증에 실패했습니다.",
"ffmpegInstallFailed": "ffmpeg.exe 자동 설치 실패: {{message}}" "ffmpegInstallFailed": "ffmpeg.exe 자동 설치 실패: {{message}}",
"baseTrackCollision": "베이스 리소스팩에 같은 트랙 ID 가 이미 있어 설치를 중단합니다: {{trackId}}\n베이스 자산을 보존하면서 새 트랙을 같은 ID 로 추가할 수 없습니다. 베이스의 sounds.json 엔트리/sounds 폴더에서 충돌하는 항목을 제거하거나 다른 베이스를 사용하세요.",
"basePaintingCollision": "베이스 리소스팩에 같은 사진 파일이 이미 있어 설치를 중단합니다: {{name}}\n베이스의 painting 텍스처를 보존하면서 같은 파일명을 추가할 수 없습니다. 베이스에서 충돌하는 파일을 제거하거나 다른 베이스를 사용하세요."
} }
} }

View File

@@ -220,6 +220,7 @@
"youtube": { "youtube": {
"ytdlpUnavailable": "yt-dlp 를 준비하지 못했습니다. (수동 입력으로 진행)", "ytdlpUnavailable": "yt-dlp 를 준비하지 못했습니다. (수동 입력으로 진행)",
"ytdlpVerifyFailed": "yt-dlp 다운로드는 됐지만 실행 검증에 실패했습니다.", "ytdlpVerifyFailed": "yt-dlp 다운로드는 됐지만 실행 검증에 실패했습니다.",
"ytdlpVerifyFailedDetail": "yt-dlp 를 사용할 수 없습니다. 시도한 경로 진단: {{detail}}",
"ytdlpInstallFailed": "yt-dlp 자동 설치에 실패했습니다: {{message}}", "ytdlpInstallFailed": "yt-dlp 자동 설치에 실패했습니다: {{message}}",
"ytdlpVideoFailed": "yt-dlp 영상 조회 실패 (code={{code}}): {{detail}}", "ytdlpVideoFailed": "yt-dlp 영상 조회 실패 (code={{code}}): {{detail}}",
"ytdlpPlaylistFailed": "yt-dlp 플레이리스트 조회 실패 (code={{code}}): {{detail}}", "ytdlpPlaylistFailed": "yt-dlp 플레이리스트 조회 실패 (code={{code}}): {{detail}}",

View File

@@ -1,6 +1,6 @@
{ {
"name": "minecraft-music-quiz-installer", "name": "minecraft-music-quiz-installer",
"version": "0.3.4", "version": "0.3.5",
"description": "마인크래프트 음악퀴즈 간편설치기 + 관리 사이트", "description": "마인크래프트 음악퀴즈 간편설치기 + 관리 사이트",
"main": "dist/installer/main.js", "main": "dist/installer/main.js",
"scripts": { "scripts": {

View File

@@ -131,6 +131,10 @@ export async function buildResourcepackZip(opts: BuildResourcepackOptions): Prom
opts.log?.(t('log.packFormatRange', { min: minFmt, max: maxFmt })) opts.log?.(t('log.packFormatRange', { min: minFmt, max: maxFmt }))
// 2) 음악 파일 복사 + sounds.json 생성/병합 // 2) 음악 파일 복사 + sounds.json 생성/병합
// 핵심 정책: 베이스 리소스팩에 이미 있는 자산은 절대 덮어쓰지 않는다.
// - 베이스 sounds.json 의 엔트리는 그대로 보존하고, 우리 트랙은 그 위에 "추가" 만 한다.
// - 베이스 sounds/track_NN.ogg 가 이미 있으면 덮어쓰지 않고 건너뛴다.
// - 키나 파일명이 충돌하면 우리 트랙을 스킵하고 로그로 알린다.
const musicFiles = (await fs.readdir(opts.musicDir)) const musicFiles = (await fs.readdir(opts.musicDir))
.filter((n) => n.toLowerCase().endsWith('.ogg')) .filter((n) => n.toLowerCase().endsWith('.ogg'))
.sort() .sort()
@@ -152,7 +156,19 @@ export async function buildResourcepackZip(opts: BuildResourcepackOptions): Prom
// NN.ogg → track_NN.ogg 로 리네임해 패키지. // NN.ogg → track_NN.ogg 로 리네임해 패키지.
const stem = path.basename(fname, path.extname(fname)) // "01" const stem = path.basename(fname, path.extname(fname)) // "01"
const trackId = `track_${stem}` const trackId = `track_${stem}`
await fs.copyFile(path.join(opts.musicDir, fname), path.join(soundsDir, `${trackId}.ogg`)) const destFile = path.join(soundsDir, `${trackId}.ogg`)
// 베이스에 같은 trackId 의 엔트리/파일이 있으면 두 선택지 다 깨진다:
// (a) 덮어쓰면 베이스의 기존 곡이 사라지고,
// (b) 새 곡을 스킵하면 데이터팩이 가리키는 곡이 빠진 채로 설치된다.
// 안전하게 설치를 즉시 실패시키고 어떤 키가 충돌했는지 알린다.
let collides = soundsJson[trackId] !== undefined
if (!collides) {
try { await fs.access(destFile); collides = true } catch { /* 없음 → OK */ }
}
if (collides) {
throw new Error(t('errors.baseTrackCollision', { trackId }))
}
await fs.copyFile(path.join(opts.musicDir, fname), destFile)
soundsJson[trackId] = { soundsJson[trackId] = {
sounds: [ sounds: [
{ name: `${NAMESPACE}:${trackId}`, stream: true } { name: `${NAMESPACE}:${trackId}`, stream: true }
@@ -160,16 +176,25 @@ export async function buildResourcepackZip(opts: BuildResourcepackOptions): Prom
} }
} }
await fs.writeFile(soundsJsonPath, JSON.stringify(soundsJson, null, 2) + '\n') await fs.writeFile(soundsJsonPath, JSON.stringify(soundsJson, null, 2) + '\n')
opts.log?.(t('log.tracksAdded', { count: musicFiles.length }))
throwIfCancelled(cancel) throwIfCancelled(cancel)
// 3) painting 텍스처 복사 (이미 cover_NN.png 형태). 같은 파일명은 덮어씀. // 3) painting 텍스처 복사 (이미 cover_NN.png 형태).
// 음악과 동일한 정책: 베이스에 같은 파일명이 이미 있으면 설치를 실패시킨다.
const paintingFiles = (await fs.readdir(opts.paintingDir)) const paintingFiles = (await fs.readdir(opts.paintingDir))
.filter((n) => n.toLowerCase().endsWith('.png')) .filter((n) => n.toLowerCase().endsWith('.png'))
.sort() .sort()
for (const fname of paintingFiles) { for (const fname of paintingFiles) {
throwIfCancelled(cancel) throwIfCancelled(cancel)
await fs.copyFile(path.join(opts.paintingDir, fname), path.join(paintingOutDir, fname)) const destFile = path.join(paintingOutDir, fname)
let collides = false
try { await fs.access(destFile); collides = true } catch { /* 없음 → OK */ }
if (collides) {
throw new Error(t('errors.basePaintingCollision', { name: fname }))
}
await fs.copyFile(path.join(opts.paintingDir, fname), destFile)
} }
opts.log?.(t('log.paintingsAdded', { count: paintingFiles.length }))
throwIfCancelled(cancel) throwIfCancelled(cancel)
// 4) zip 으로 묶기. 이 단계가 가장 길어서 별도로 cancel 폴링이 들어간다. // 4) zip 으로 묶기. 이 단계가 가장 길어서 별도로 cancel 폴링이 들어간다.

View File

@@ -32,48 +32,47 @@ function getYtDlpAssetName(): string {
return 'yt-dlp' // 그 외 OS: 순수 파이썬 zipapp. python3 가 PATH 에 있어야 동작 return 'yt-dlp' // 그 외 OS: 순수 파이썬 zipapp. python3 가 PATH 에 있어야 동작
} }
/** 로컬 설치 경로: %appdata%/.mc_custom/<asset> */ /**
* 로컬 설치 경로: OS별 사용자 데이터 디렉터리 안의 .mc_custom/<asset>.
* - Windows: %APPDATA%/.mc_custom/yt-dlp.exe
* - macOS : ~/Library/Application Support/.mc_custom/yt-dlp_macos
* - Linux 등: $XDG_CONFIG_HOME 또는 ~/.config/.mc_custom/yt-dlp_linux (arch 따라 다름)
*/
export function getYtDlpInstallPath(): string { export function getYtDlpInstallPath(): string {
return path.join(getMcCustomDir(), getYtDlpAssetName()) return path.join(getMcCustomDir(), getYtDlpAssetName())
} }
/** 순수 파이썬 zipapp(`yt-dlp`) 의 로컬 설치 경로. python3 가 PATH 에 있어야 동작. */
function getYtDlpZipappPath(): string {
return path.join(getMcCustomDir(), 'yt-dlp_zipapp')
}
/** 한 번에 한 다운로드만 진행하도록 락 (서버 동시 요청 보호). */ /** 한 번에 한 다운로드만 진행하도록 락 (서버 동시 요청 보호). */
let installPromise: Promise<string> | null = null let installPromise: Promise<string> | null = null
type ProbeResult = { ok: true } | { ok: false; detail: string }
/** /**
* %appdata%/.mc_custom/ 에 yt-dlp 가 준비됐는지 확인하고, 없으면 GitHub Releases 에서 * .mc_custom/ 디렉터리에 yt-dlp 가 준비됐는지 확인하고, 없으면 GitHub Releases 에서
* 현재 OS/아키텍처용 바이너리를 자동으로 받아 설치한다. 성공 시 실행 경로 반환. * 현재 OS/아키텍처용 네이티브 바이너리를 자동으로 받아 설치한다. 성공 시 실행 경로 반환.
*
* 네이티브 바이너리가 실행되지 않는 환경(glibc 미스매치, musl libc, antivirus 차단 등)
* 이면 다음 순서로 폴백한다:
* 1) PATH 의 `yt-dlp(.exe)` (시스템에 따로 깐 거)
* 2) (POSIX 한정) 범용 파이썬 zipapp `yt-dlp` 를 다운로드 후 shebang 실행 — python3 필요
* 전부 실패하면 각 시도의 진단정보가 포함된 에러를 던진다.
*/ */
export async function ensureYtDlp(): Promise<string> { export async function ensureYtDlp(): Promise<string> {
const target = getYtDlpInstallPath() const target = getYtDlpInstallPath()
// 이미 설치돼 있고 실행 가능하면 그대로 사용 // Fast path: 이미 설치돼 있고 실행도 잘 되면 그대로 사용
if (await canExecute(target)) return target if (await fileExists(target)) {
const probe = await probeVersion(target)
if (probe.ok) return target
}
if (installPromise) return installPromise if (installPromise) return installPromise
installPromise = (async () => { installPromise = (async () => {
try { try {
const dir = getMcCustomDir() return await prepareYtDlp(target)
await fs.mkdir(dir, { recursive: true })
const asset = getYtDlpAssetName()
const url = `https://github.com/yt-dlp/yt-dlp/releases/latest/download/${asset}`
await downloadToFile(url, target)
// POSIX 계열은 실행 권한 부여
if (process.platform !== 'win32') {
await fs.chmod(target, 0o755)
}
// 검증
const okVersion = await probeVersion(target)
if (!okVersion) {
throw new YtDlpUnavailableError(t('youtube.ytdlpVerifyFailed'))
}
return target
} catch (err) {
// 실패 흔적(부분 다운로드) 삭제
try { await fs.unlink(target) } catch { /* noop */ }
throw err instanceof YtDlpUnavailableError
? err
: new YtDlpUnavailableError(
t('youtube.ytdlpInstallFailed', { message: err instanceof Error ? err.message : String(err) })
)
} finally { } finally {
installPromise = null installPromise = null
} }
@@ -81,31 +80,108 @@ export async function ensureYtDlp(): Promise<string> {
return installPromise return installPromise
} }
async function canExecute(filePath: string): Promise<boolean> { async function prepareYtDlp(target: string): Promise<string> {
const diagnostics: string[] = []
// 1. 기존 파일이 있으면 우선 그걸로 시도
if (await fileExists(target)) {
const probe = await probeVersion(target)
if (probe.ok) return target
diagnostics.push(`기존 ${path.basename(target)} 검증 실패: ${probe.detail}`)
}
// 2. PATH 에 yt-dlp(.exe) 가 시스템 전역으로 설치돼 있으면 그걸 사용
const pathCmd = process.platform === 'win32' ? 'yt-dlp.exe' : 'yt-dlp'
const pathProbe = await probeVersion(pathCmd)
if (pathProbe.ok) return pathCmd
diagnostics.push(`PATH 의 ${pathCmd} 사용 불가: ${pathProbe.detail}`)
// 3. 최후 수단: 새로 다운로드해서 시도
try {
await fs.mkdir(getMcCustomDir(), { recursive: true })
const asset = getYtDlpAssetName()
const url = `https://github.com/yt-dlp/yt-dlp/releases/latest/download/${asset}`
try { await fs.unlink(target) } catch { /* noop */ }
await downloadToFile(url, target)
if (process.platform !== 'win32') {
await fs.chmod(target, 0o755)
} else {
// Windows: 인터넷에서 받은 파일에는 NTFS ADS 'Zone.Identifier' 가 붙어
// SmartScreen/Attachment Manager 가 실행을 막을 수 있다. 베스트에포트로 제거.
try { await fs.unlink(`${target}:Zone.Identifier`) } catch { /* noop */ }
}
const probe = await probeVersion(target)
if (probe.ok) return target
diagnostics.push(`새로 받은 ${asset} 검증 실패: ${probe.detail}`)
try { await fs.unlink(target) } catch { /* noop */ }
} catch (err) {
diagnostics.push(`다운로드 실패: ${err instanceof Error ? err.message : String(err)}`)
try { await fs.unlink(target) } catch { /* noop */ }
}
// 4. POSIX 한정 최후 폴백: 범용 파이썬 zipapp `yt-dlp` 다운로드 후 shebang 실행.
// 네이티브 바이너리가 glibc/musl/arch 문제로 못 도는 리눅스 환경이라도
// python3 가 PATH 에 있으면 동작한다. ~ 3MB 짜리 스크립트.
if (process.platform !== 'win32') {
const zipappPath = getYtDlpZipappPath()
try {
try { await fs.unlink(zipappPath) } catch { /* noop */ }
await downloadToFile('https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp', zipappPath)
await fs.chmod(zipappPath, 0o755)
const probe = await probeVersion(zipappPath)
if (probe.ok) return zipappPath
diagnostics.push(`zipapp yt-dlp 검증 실패: ${probe.detail} (python3 누락이거나 PATH 에 없음)`)
try { await fs.unlink(zipappPath) } catch { /* noop */ }
} catch (err) {
diagnostics.push(`zipapp 다운로드 실패: ${err instanceof Error ? err.message : String(err)}`)
try { await fs.unlink(zipappPath) } catch { /* noop */ }
}
}
throw new YtDlpUnavailableError(
t('youtube.ytdlpVerifyFailedDetail', { detail: diagnostics.join(' | ') })
)
}
async function fileExists(filePath: string): Promise<boolean> {
try { try {
await fs.access(filePath, fsConst.F_OK) await fs.access(filePath, fsConst.F_OK)
return true
} catch { } catch {
return false return false
} }
// POSIX 면 X 비트도 확인
if (process.platform !== 'win32') {
try {
await fs.access(filePath, fsConst.X_OK)
} catch {
return false
}
}
// 실제로 --version 으로 한 번 더 확인
return probeVersion(filePath)
} }
function probeVersion(bin: string): Promise<boolean> { function probeVersion(bin: string): Promise<ProbeResult> {
return new Promise((resolve) => { return new Promise((resolve) => {
const child = spawn(bin, ['--version'], { stdio: ['ignore', 'pipe', 'pipe'] }) let child: ReturnType<typeof spawn>
let ok = false try {
child.stdout.on('data', () => { ok = true }) child = spawn(bin, ['--version'], { stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true })
child.on('error', () => resolve(false)) } catch (err) {
child.on('close', (code) => resolve(ok && code === 0)) resolve({ ok: false, detail: `spawn throw: ${err instanceof Error ? err.message : String(err)}` })
return
}
let stdout = ''
let stderr = ''
child.stdout?.on('data', (chunk: Buffer) => { stdout += chunk.toString('utf8') })
child.stderr?.on('data', (chunk: Buffer) => { stderr += chunk.toString('utf8') })
child.on('error', (err: NodeJS.ErrnoException) => {
const code = err.code ? `${err.code} ` : ''
resolve({ ok: false, detail: `spawn error: ${code}${err.message}` })
})
child.on('close', (code, signal) => {
const out = stdout.trim()
if (out && code === 0) {
resolve({ ok: true })
return
}
const parts: string[] = []
parts.push(`exit=${code === null ? `signal:${signal}` : code}`)
if (!out) parts.push('stdout=(empty)')
const errLine = stderr.trim().split('\n')[0]
if (errLine) parts.push(`stderr="${errLine.slice(0, 200)}"`)
resolve({ ok: false, detail: parts.join(', ') })
})
}) })
} }