mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-18 23:44:59 +01:00
widen search paths / fix vector-im/riot-web#13190
This does two things related to search paths: - also search for webapp symlink in the case of packaged applications (e.g. Archlinux used to provide a symlink this way, linking to a riot-web copy installed elsewhere, instead of creating an asar of it) - also take dirname(asarPath) as a valid resources path, as this is how riot-desktop currently is packaged. Fixes vector-im/riot-web#13190.
This commit is contained in:
parent
71267c65c1
commit
f0c68e0b39
@ -96,9 +96,9 @@ if (userDataPathInProtocol) {
|
||||
app.setPath('userData', `${app.getPath('userData')}-${argv['profile']}`);
|
||||
}
|
||||
|
||||
async function tryAsarPaths(rawPaths) {
|
||||
// Make everything relative to the current file
|
||||
const paths = rawPaths.map(p => path.join(__dirname, p));
|
||||
async function tryPaths(name, root, rawPaths) {
|
||||
// Make everything relative to root
|
||||
const paths = rawPaths.map(p => path.join(root, p));
|
||||
|
||||
for (const p of paths) {
|
||||
try {
|
||||
@ -107,27 +107,35 @@ async function tryAsarPaths(rawPaths) {
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
console.log("Couldn't find webapp files in any of: ");
|
||||
console.log(`Couldn't find ${name} files in any of: `);
|
||||
for (const p of paths) {
|
||||
console.log("\t"+path.resolve(p));
|
||||
}
|
||||
throw new Error("Failed to find webapp files");
|
||||
throw new Error(`Failed to find ${name} files`);
|
||||
}
|
||||
|
||||
// Find the webapp resources and set up things that require them
|
||||
async function setupGlobals() {
|
||||
// find the webapp asar.
|
||||
asarPath = await tryAsarPaths([
|
||||
asarPath = await tryPaths("webapp", __dirname, [
|
||||
// If run from the source checkout, this will be in the directory above
|
||||
'../webapp.asar',
|
||||
// but if run from a packaged application, electron-main.js will be in
|
||||
// a different asar file so it will be two levels above
|
||||
'../../webapp.asar',
|
||||
// also try without the 'asar' suffix to allow symlinking in a directory
|
||||
// also try without the 'asar' suffix to allow symlinking in a directory
|
||||
'../webapp',
|
||||
// from a packaged application
|
||||
'../../webapp',
|
||||
]);
|
||||
|
||||
// we assume the resources path is in the same place as the asar
|
||||
resPath = path.join(path.dirname(asarPath), 'res');
|
||||
resPath = await tryPaths("res", path.dirname(asarPath), [
|
||||
// If run from the source checkout
|
||||
'res',
|
||||
// if run from packaged application
|
||||
'',
|
||||
]);
|
||||
|
||||
try {
|
||||
vectorConfig = require(asarPath + 'config.json');
|
||||
|
Loading…
Reference in New Issue
Block a user