Skip to content

Commit df2cc7e

Browse files
xenhatxenhat
authored andcommitted
WIP: rework path comparison logic
1 parent 70d0272 commit df2cc7e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/process/index.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,24 @@ export default class ProcessServer {
111111
else {
112112
newPath = path;
113113
}
114-
newPath = newPath.substr(newPath.lastIndexOf('/') + 1);
114+
// newPath = newPath.substr(newPath.lastIndexOf('/') + 1);
115+
// newPath = path.split('/').slice(-2).join('/');
115116

116117
// log(`performance checkpoint: ${(performance.now() - startTime).toFixed(2)}ms`);
117118

118-
toCompare.push(newPath);
119+
// add the original path
120+
toCompare.push(path);
121+
// toCompare.push(newPath);
119122
if (path.includes('.exe')) {
120123
const part2 = path.split('/').slice(-2).join('/');
121124
toCompare.push(part2);
122125
replaceAll(toCompare, bitness_suffixes);
123126
}
127+
for (const inlist of toCompare) {
128+
if (inlist.includes('valheim')) {
129+
debug(`ToCompare: ${inlist}`)
130+
}
131+
}
124132

125133
// TODO: Convert into an inline function similar to findInObjArray
126134
// TODO: Don't try to match the running executable more than once
@@ -138,7 +146,8 @@ export default class ProcessServer {
138146
}
139147
} else {
140148
if (
141-
toCompare.some((running) => {
149+
toCompare.some((running_raw) => {
150+
const running = running_raw.split('/').slice(-2).join('/'); // Format used by many of discord's database
142151
// explicit match first
143152
if (known_exe.name === running) {
144153
// debug(`Match Level 2: "${name}" via ${known_exe.name} <==> ${running}`)
@@ -149,6 +158,10 @@ export default class ProcessServer {
149158
// debug(`Match Level 3: "${name}" via ${known_exe.name} <==> ${running}`)
150159
return true
151160
}
161+
if (known_exe.name === running.replace('.x86_64','.exe')) {
162+
// debug(`Match Level 3.1: "${name}" via ${known_exe.name} <==> ${running}`)
163+
return true
164+
}
152165
// Try comparing against an exe-less version (mistake in database)
153166
if (known_exe.name === running.replace('.exe', '')) {
154167
// debug(`Match Level 4: "${name}" via ${known_exe.name} <==> ${running}`)

0 commit comments

Comments
 (0)