guard prefix and wine edits while their apps run

This commit is contained in:
olcxja 2026-10-02 14:46:21 +02:00
commit 38eea05789
9 changed files with 170 additions and 39 deletions

View file

@ -5,6 +5,7 @@ const fs = require('fs')
const { spawn } = require('child_process')
const { DIRS } = require('./paths')
const { prefixPath } = require('./prefixes')
const { prefixNameForGame } = require('./library')
// The fake Steam install Proton is pointed at through
// STEAM_COMPAT_CLIENT_INSTALL_PATH. Both folders Proton links into its prefix
@ -18,13 +19,6 @@ function ensureFakeSteam() {
return fake
}
// The prefix a run will use, by NAME (buildEnv resolves the same fallback).
function prefixNameFor(game) {
if (game && game.prefix) return game.prefix
const defs = require('./prefixes').listPrefixes()
return defs.default || 'default'
}
// Wine only ever repairs links that are BROKEN: a prefix that came from
// another machine (or from an older PLWL) can still hold absolute links into
// its build that happen to resolve here, and those would be synced out again.
@ -32,7 +26,7 @@ function prefixNameFor(game) {
// costs a single walk in the common (already relative) case.
const healedPrefixes = new Set()
async function healPrefixOnce(game) {
const name = prefixNameFor(game)
const name = prefixNameForGame(game)
const key = `${name}\u0000${DIRS.BUILD}`
if (!name || healedPrefixes.has(key)) return 0
healedPrefixes.add(key)
@ -78,11 +72,9 @@ function linkPrefix(compatData, prefixDir) {
function buildEnv({ game, wine }) {
const env = { ...process.env }
const isProton = wine && wine.type === 'proton'
let prefixDir = game.prefix ? prefixPath(game.prefix) : null
if (!prefixDir) {
const defs = require('./prefixes').listPrefixes()
prefixDir = prefixPath(defs.default || 'default')
}
// same fallback the games service snapshots into its running entries
// (library.prefixNameForGame), so in-use checks always name this folder
const prefixDir = prefixPath(prefixNameForGame(game))
if (isProton) {
const fakeSteam = ensureFakeSteam()