installer: move yt-dlp/ffmpeg under .mc_custom/installer/, clean platform-cache
- yt-dlp.exe, ffmpeg.exe now live in %appdata%/.mc_custom/installer/ so the .mc_custom root stays a clean Minecraft game folder. Existing binaries at the old location are migrated on first run. - After a successful install, the platform-cache (downloaded fabric / forge / neoforge installer jars) is deleted — it's regenerable and was just wasting disk space. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import { promises as fs, createWriteStream, constants as fsConst } from 'node:fs
|
||||
import path from 'node:path'
|
||||
import https from 'node:https'
|
||||
import http from 'node:http'
|
||||
import { getMcCustomDir } from '../shared/paths.js'
|
||||
import { getMcCustomDir, getMcCustomInstallerDir } from '../shared/paths.js'
|
||||
import { loadComponentI18n } from '../shared/i18n.js'
|
||||
|
||||
const { t } = loadComponentI18n('installer-rp')
|
||||
@@ -13,10 +13,30 @@ const extractZip: (source: string, options: { dir: string }) => Promise<void> =
|
||||
|
||||
/**
|
||||
* 리소스팩 간편설치기는 Windows .exe 로 배포되므로 ffmpeg.exe 한 종류만 사용.
|
||||
* 경로: %appdata%/.mc_custom/ffmpeg.exe
|
||||
* 경로: %appdata%/.mc_custom/installer/ffmpeg.exe
|
||||
*/
|
||||
export function getFfmpegExePath(): string {
|
||||
return path.join(getMcCustomDir(), 'ffmpeg.exe')
|
||||
return path.join(getMcCustomInstallerDir(), 'ffmpeg.exe')
|
||||
}
|
||||
|
||||
/**
|
||||
* 0.2.1 이전 버전이 `.mc_custom/ffmpeg.exe` 에 받아둔 파일이 있으면 새 위치로
|
||||
* 옮긴다.
|
||||
*/
|
||||
async function migrateLegacyExe(target: string): Promise<void> {
|
||||
const legacy = path.join(getMcCustomDir(), 'ffmpeg.exe')
|
||||
if (legacy === target) return
|
||||
try {
|
||||
await fs.access(legacy, fsConst.F_OK)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await fs.mkdir(path.dirname(target), { recursive: true })
|
||||
await fs.rename(legacy, target)
|
||||
} catch {
|
||||
try { await fs.unlink(legacy) } catch { /* noop */ }
|
||||
}
|
||||
}
|
||||
|
||||
/** BtbN/FFmpeg-Builds 의 win64-gpl 빌드. zip 내부에 bin/ffmpeg.exe 가 들어 있음. */
|
||||
@@ -33,6 +53,7 @@ export async function ensureFfmpegExe(
|
||||
log?: (line: string) => void
|
||||
): Promise<string> {
|
||||
const target = getFfmpegExePath()
|
||||
await migrateLegacyExe(target)
|
||||
if (await canExecute(target)) {
|
||||
log?.(t('log.ffmpegExists', { path: target }))
|
||||
return target
|
||||
@@ -40,7 +61,7 @@ export async function ensureFfmpegExe(
|
||||
if (installPromise) return installPromise
|
||||
|
||||
installPromise = (async () => {
|
||||
const dir = getMcCustomDir()
|
||||
const dir = getMcCustomInstallerDir()
|
||||
const zipPath = path.join(dir, '.tmp_ffmpeg.zip')
|
||||
const extractDir = path.join(dir, '.tmp_ffmpeg')
|
||||
try {
|
||||
|
||||
@@ -3,17 +3,38 @@ import { promises as fs, createWriteStream, constants as fsConst } from 'node:fs
|
||||
import path from 'node:path'
|
||||
import https from 'node:https'
|
||||
import http from 'node:http'
|
||||
import { getMcCustomDir } from '../shared/paths.js'
|
||||
import { getMcCustomDir, getMcCustomInstallerDir } from '../shared/paths.js'
|
||||
import { loadComponentI18n } from '../shared/i18n.js'
|
||||
|
||||
const { t } = loadComponentI18n('installer-rp')
|
||||
|
||||
/**
|
||||
* 리소스팩 간편설치기는 Windows .exe 로 배포되므로 yt-dlp.exe 한 종류만 사용.
|
||||
* 경로: %appdata%/.mc_custom/yt-dlp.exe
|
||||
* 경로: %appdata%/.mc_custom/installer/yt-dlp.exe
|
||||
*/
|
||||
export function getYtDlpExePath(): string {
|
||||
return path.join(getMcCustomDir(), 'yt-dlp.exe')
|
||||
return path.join(getMcCustomInstallerDir(), 'yt-dlp.exe')
|
||||
}
|
||||
|
||||
/**
|
||||
* 0.2.1 이전 버전이 `.mc_custom/yt-dlp.exe` 에 받아둔 파일이 있으면 새 위치로
|
||||
* 옮긴다. 마인크래프트 게임 폴더 루트가 외부 도구 파일로 더럽혀지지 않도록.
|
||||
*/
|
||||
async function migrateLegacyExe(target: string): Promise<void> {
|
||||
const legacy = path.join(getMcCustomDir(), 'yt-dlp.exe')
|
||||
if (legacy === target) return
|
||||
try {
|
||||
await fs.access(legacy, fsConst.F_OK)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await fs.mkdir(path.dirname(target), { recursive: true })
|
||||
await fs.rename(legacy, target)
|
||||
} catch {
|
||||
// 권한·드라이브 문제 등으로 실패하면 그냥 새로 받으면 되므로 무시.
|
||||
try { await fs.unlink(legacy) } catch { /* noop */ }
|
||||
}
|
||||
}
|
||||
|
||||
const YT_DLP_DOWNLOAD_URL =
|
||||
@@ -29,6 +50,7 @@ export async function ensureYtDlpExe(
|
||||
log?: (line: string) => void
|
||||
): Promise<string> {
|
||||
const target = getYtDlpExePath()
|
||||
await migrateLegacyExe(target)
|
||||
if (await canExecute(target)) {
|
||||
log?.(t('log.ytdlpExists', { path: target }))
|
||||
return target
|
||||
|
||||
Reference in New Issue
Block a user