mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 07:08:55 +02:00
feat(desktop): use unique appdata if port is different
This commit is contained in:
parent
0fcff6639f
commit
a840d91379
@ -11,7 +11,7 @@
|
||||
"url": "https://github.com/TriliumNext/Notes"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "cross-env TRILIUM_PORT=37741 TRILIUM_DATA_DIR=data tsx ../../scripts/electron-start.mts src/main.ts",
|
||||
"dev": "cross-env TRILIUM_PORT=37742 TRILIUM_DATA_DIR=data tsx ../../scripts/electron-start.mts src/main.ts",
|
||||
"start-no-dir": "cross-env TRILIUM_PORT=37743 tsx ../../scripts/electron-start.mts src/main.ts",
|
||||
"build": "tsx scripts/build.ts",
|
||||
"start-prod": "pnpm build && cross-env TRILIUM_DATA_DIR=data TRILIUM_PORT=37841 ELECTRON_IS_DEV=0 electron dist",
|
||||
|
@ -10,8 +10,13 @@ import electronDebug from "electron-debug";
|
||||
import electronDl from "electron-dl";
|
||||
import { deferred } from "@triliumnext/server/src/services/utils.js";
|
||||
import { PRODUCT_NAME } from "./app-info";
|
||||
import port from "@triliumnext/server/src/services/port.js";
|
||||
import { join } from "path";
|
||||
|
||||
async function main() {
|
||||
const userDataPath = getUserData();
|
||||
app.setPath("userData", userDataPath);
|
||||
|
||||
const serverInitializedPromise = deferred<void>();
|
||||
|
||||
// Prevent Trilium starting twice on first install and on uninstall for the Windows installer.
|
||||
@ -89,6 +94,14 @@ async function main() {
|
||||
serverInitializedPromise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique user data directory for Electron so that single instance locks between legitimately different instances such as different port or data directory can still act independently, but we are focusing the main window otherwise.
|
||||
*/
|
||||
function getUserData() {
|
||||
const name = `${app.getName()}-${port}`;
|
||||
return join(app.getPath("appData"), name);
|
||||
}
|
||||
|
||||
async function onReady() {
|
||||
// app.setAppUserModelId('com.github.zadam.trilium');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user