Skip to content

Commit a4600ff

Browse files
committed
rework path comparison logic
This fixes Valheim (Linux Native) and probably several more.
1 parent 70d0272 commit a4600ff

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

src/process/index.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,31 +96,27 @@ export default class ProcessServer {
9696
if (pid === 1) continue // init system
9797
if (_path.length < 1) continue; // process has no name, i.e. kernel thread
9898
if (_path.startsWith('/proc')) continue; // internal *nix stuff
99-
if (_path.startsWith('/usr/lib/')) continue; // internal *nix stuff
99+
// if (_path.startsWith('/usr/lib/')) continue; // internal *nix stuff
100100
if (_path.includes('systemd')) continue;
101101
const cwdPath = _cwdPath.toLowerCase().replaceAll('\\', '/');
102102
const path = _path.toLowerCase().replaceAll('\\', '/');
103103
if (path.startsWith('c:/windows')) continue // system processes (wine)
104104
if (_path.includes('webhelper')) continue; // CEF Processes
105105
if (_path.endsWith('dolphin')) continue; // KDE file manager, not Dolphin Emulator
106106
const toCompare = [];
107-
let newPath
108-
if (path.includes(' --')) {
109-
newPath = path.split(' --')[0];
110-
}
111-
else {
112-
newPath = path;
113-
}
114-
newPath = newPath.substr(newPath.lastIndexOf('/') + 1);
115-
116107
// log(`performance checkpoint: ${(performance.now() - startTime).toFixed(2)}ms`);
117-
118-
toCompare.push(newPath);
108+
toCompare.push(path);
109+
// toCompare.push(newPath);
119110
if (path.includes('.exe')) {
120111
const part2 = path.split('/').slice(-2).join('/');
121112
toCompare.push(part2);
122113
replaceAll(toCompare, bitness_suffixes);
123114
}
115+
for (const inlist of toCompare) {
116+
if (inlist.includes('valheim')) {
117+
debug(`ToCompare: ${inlist}`)
118+
}
119+
}
124120

125121
// TODO: Convert into an inline function similar to findInObjArray
126122
// TODO: Don't try to match the running executable more than once
@@ -138,7 +134,8 @@ export default class ProcessServer {
138134
}
139135
} else {
140136
if (
141-
toCompare.some((running) => {
137+
toCompare.some((running_raw) => {
138+
const running = running_raw.split('/').slice(-2).join('/'); // Format used by many of discord's database
142139
// explicit match first
143140
if (known_exe.name === running) {
144141
// debug(`Match Level 2: "${name}" via ${known_exe.name} <==> ${running}`)
@@ -149,6 +146,10 @@ export default class ProcessServer {
149146
// debug(`Match Level 3: "${name}" via ${known_exe.name} <==> ${running}`)
150147
return true
151148
}
149+
if (known_exe.name === running.replace('.x86_64','.exe')) {
150+
// debug(`Match Level 3.1: "${name}" via ${known_exe.name} <==> ${running}`)
151+
return true
152+
}
152153
// Try comparing against an exe-less version (mistake in database)
153154
if (known_exe.name === running.replace('.exe', '')) {
154155
// debug(`Match Level 4: "${name}" via ${known_exe.name} <==> ${running}`)

0 commit comments

Comments
 (0)