code cleanup

This commit is contained in:
olcxja 2026-10-07 16:29:40 +02:00
commit d21b873327
12 changed files with 40 additions and 213 deletions

View file

@ -88,28 +88,16 @@ async function healPrefixOnce(game) {
}
}
// Proton's STEAM_COMPAT_DATA_PATH must be a symlink to the launcher prefix.
// A leftover EMPTY compat dir (an older PLWL bug) is replaced by the link; a
// populated one is left alone.
// Proton's STEAM_COMPAT_DATA_PATH must be a symlink to the launcher prefix;
// a real compat dir already sitting there is not ours to replace.
function linkPrefix(compatData, prefixDir) {
try {
fs.mkdirSync(path.dirname(compatData), { recursive: true })
} catch {}
try {
const st = fs.lstatSync(compatData)
if (st.isSymbolicLink()) {
if (fs.readlinkSync(compatData) === prefixDir) return
fs.unlinkSync(compatData)
} else if (st.isDirectory()) {
let names = []
try {
names = fs.readdirSync(compatData)
} catch {}
if (names.length) return
fs.rmdirSync(compatData)
} else {
return
}
if (!fs.lstatSync(compatData).isSymbolicLink()) return
if (fs.readlinkSync(compatData) === prefixDir) return
fs.unlinkSync(compatData)
} catch {}
try {
fs.symlinkSync(prefixDir, compatData, 'dir')