From b442363f387f68183880e8c24c71c0b980a5fbfb Mon Sep 17 00:00:00 2001 From: olcxja Date: Sat, 26 Sep 2026 15:45:11 +0200 Subject: [PATCH] patch absolute paths --- package.json | 4 ++-- renderer/app.js | 2 +- src/wines.js | 25 ++++++++++++++++++------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index a60da0b..a672702 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "main": "src/main.js", "scripts": { "start": "electron .", - "test": "node test/import.test.js && node test/icons.test.js && node test/shortcuts.test.js", - "smoke": "node test/import.test.js && node test/icons.test.js && node test/shortcuts.test.js" + "test": "node test/import.test.js && node test/icons.test.js && node test/shortcuts.test.js && node test/wines-portable.test.js", + "smoke": "node test/import.test.js && node test/icons.test.js && node test/shortcuts.test.js && node test/wines-portable.test.js" }, "devDependencies": { "@electron/asar": "^3.4.1", diff --git a/renderer/app.js b/renderer/app.js index 6c1c0d8..08874d0 100644 --- a/renderer/app.js +++ b/renderer/app.js @@ -576,7 +576,7 @@ function renderWines() { ` row.querySelector('.title').textContent = w.label - row.querySelector('.sub').textContent = w.path || t('wines.systemHint') + row.querySelector('.sub').textContent = displayPath(w.path) || t('wines.systemHint') row.querySelector('.sub').title = row.querySelector('.sub').textContent const defBtn = row.querySelector('[data-act=default]') defBtn.textContent = t('wines.makeDefault') diff --git a/src/wines.js b/src/wines.js index 7669168..fc761cd 100644 --- a/src/wines.js +++ b/src/wines.js @@ -3,7 +3,7 @@ const fs = require('fs') const fsp = fs.promises const path = require('path') -const { DIRS, readJson, writeJson } = require('./paths') +const { DIRS, readJson, writeJson, toPortablePath, resolvePortablePath } = require('./paths') const { dedupeDir } = require('./fsutil') const WINES_DIR = DIRS.WINES @@ -106,7 +106,7 @@ async function refreshWines() { } catch { found = [] } - const prev = readJson(REGISTRY, []) + const prev = readJson(REGISTRY, []).map(wineAbs) const prevById = new Map(prev.map(w => [w.id, w])) // A build whose path changed since last scan was moved (or the launcher // itself was) - rewire its absolute symlinks to the current location. @@ -120,12 +120,22 @@ async function refreshWines() { } const disabled = new Set(prev.filter(w => w.disabled).map(w => w.id)) for (const w of found) if (disabled.has(w.id)) w.disabled = true - writeJson(REGISTRY, found) + writeJson(REGISTRY, found.map(wineRel)) return found } +// Stored relative to FILES (portable), resolved to absolute for use - same +// scheme as the game registry. `id`, `name`, `label`, `version`, `type` pass through. +function wineAbs(w) { + return { ...w, path: resolvePortablePath(w.path), wineBin: resolvePortablePath(w.wineBin) } +} + +function wineRel(w) { + return { ...w, path: toPortablePath(w.path), wineBin: toPortablePath(w.wineBin) } +} + function getWines() { - return readJson(REGISTRY, []) + return readJson(REGISTRY, []).map(wineAbs) } function getWine(id) { @@ -137,7 +147,7 @@ function setWineDisabled(id, disabled) { const w = wines.find(x => x.id === id) if (w) { w.disabled = !!disabled - writeJson(REGISTRY, wines) + writeJson(REGISTRY, wines.map(wineRel)) } return wines } @@ -160,7 +170,7 @@ function deleteWine(id) { try { fs.rmSync(w.path, { recursive: true, force: true }) } catch {} - writeJson(REGISTRY, wines.filter(x => x.id !== id)) + writeJson(REGISTRY, wines.filter(x => x.id !== id).map(wineRel)) if (getDefaultWine() === id) require('./library').saveSettings({ defaultWine: 'system' }) return { ok: true } } @@ -262,7 +272,8 @@ async function importWineFolder(srcDir) { symlinksFixed = await fixBuildSymlinks(dst) } catch {} await refreshWines() - return { ok: true, path: dst, symlinksFixed } + // the toast shows a portable-looking path (files/...) like everywhere else + return { ok: true, path: toPortablePath(dst), symlinksFixed } } module.exports = { refreshWines, getWines, getWine, setWineDisabled, getDefaultWine, setDefaultWine, deleteWine, importWineFolder, findWineBinary, detectType, fixBuildSymlinks }