code cleanup
This commit is contained in:
parent
4680d7f014
commit
d21b873327
12 changed files with 40 additions and 213 deletions
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue