mirror of
https://github.com/zadam/trilium.git
synced 2026-05-07 05:47:26 +02:00
feat(electron): customizable Electron directory (closes #4192)
This commit is contained in:
@@ -101,9 +101,22 @@ async function main() {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* When running in portable mode (TRILIUM_DATA_DIR is set), the user data is stored inside the data directory
|
||||
* so that no files are written to the system's roaming profile (e.g. %APPDATA% on Windows).
|
||||
* This can be overridden by setting TRILIUM_ELECTRON_DATA_DIR to a custom path.
|
||||
*/
|
||||
function getUserData() {
|
||||
if (process.env.TRILIUM_ELECTRON_DATA_DIR) {
|
||||
return process.env.TRILIUM_ELECTRON_DATA_DIR;
|
||||
}
|
||||
|
||||
const name = `${app.getName()}-${port}`;
|
||||
|
||||
if (process.env.TRILIUM_DATA_DIR) {
|
||||
return join(process.env.TRILIUM_DATA_DIR, "electron-user-data", name);
|
||||
}
|
||||
|
||||
return join(app.getPath("appData"), name);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,14 @@ TRILIUM_DATA_DIR=/home/myuser/data/my-trilium-data trilium
|
||||
|
||||
You can then save the above command as a shell script on your path for convenience.
|
||||
|
||||
## Electron user data directory (desktop only)
|
||||
|
||||
When running the desktop application, Electron stores internal data (caches, spell-check dictionaries, session storage, etc.) separately from the Trilium data directory. By default this goes to the system's application data folder (e.g. `%APPDATA%` on Windows), which may be undesirable in corporate environments with roaming profiles or when running in portable mode.
|
||||
|
||||
When `TRILIUM_DATA_DIR` is set (e.g. via the `trilium-portable` script), the Electron user data is automatically redirected into `${TRILIUM_DATA_DIR}/electron-user-data/`, so no files are written to the system's roaming profile.
|
||||
|
||||
If you need to store the Electron data in a different location than the Trilium data directory, you can set the `TRILIUM_ELECTRON_DATA_DIR` environment variable to an explicit path.
|
||||
|
||||
## Fine-grained directory/path location
|
||||
|
||||
Apart from the data directory, some of the subdirectories of it can be moved elsewhere by changing an environment variable:
|
||||
@@ -88,4 +96,5 @@ Apart from the data directory, some of the subdirectories of it can be moved els
|
||||
| `TRILIUM_LOG_DIR` | `${TRILIUM_DATA_DIR}/log` | Directory where daily <a class="reference-link" href="../Troubleshooting/Error%20logs/Backend%20(server)%20logs.md">Backend (server) logs</a> are stored. |
|
||||
| `TRILIUM_TMP_DIR` | `${TRILIUM_DATA_DIR}/tmp` | Directory where temporary files are stored (for example when opening in an external app). |
|
||||
| `TRILIUM_ANONYMIZED_DB_DIR` | `${TRILIUM_DATA_DIR}/anonymized-db` | Directory where a <a class="reference-link" href="../Troubleshooting/Anonymized%20Database.md">Anonymized Database</a> is stored. |
|
||||
| `TRILIUM_CONFIG_INI_PATH` | `${TRILIUM_DATA_DIR}/config.ini` | Path to <a class="reference-link" href="../Advanced%20Usage/Configuration%20(config.ini%20or%20e.md">Configuration (config.ini or environment variables)</a> file. |
|
||||
| `TRILIUM_CONFIG_INI_PATH` | `${TRILIUM_DATA_DIR}/config.ini` | Path to <a class="reference-link" href="../Advanced%20Usage/Configuration%20(config.ini%20or%20e.md">Configuration (config.ini or environment variables)</a> file. |
|
||||
| `TRILIUM_ELECTRON_DATA_DIR` | `${TRILIUM_DATA_DIR}/electron-user-data` (portable) or system appData (default) | Directory where Electron stores internal data such as caches and spell-check dictionaries (desktop only). |
|
||||
|
||||
@@ -11,7 +11,7 @@ Trilium offers various startup scripts to customize your experience:
|
||||
|
||||
* `trilium-no-cert-check`: Starts Trilium without validating [TLS certificates](Server%20Installation/HTTPS%20\(TLS\).md), useful if connecting to a server with a self-signed certificate.
|
||||
* Alternatively, set the `NODE_TLS_REJECT_UNAUTHORIZED=0` environment variable before starting Trilium.
|
||||
* `trilium-portable`: Launches Trilium in portable mode, where the [data directory](Data%20directory.md) is created within the application's directory, making it easy to move the entire setup.
|
||||
* `trilium-portable`: Launches Trilium in portable mode, where the [data directory](Data%20directory.md) is created within the application's directory, making it easy to move the entire setup. Electron's internal data (caches, dictionaries, etc.) is also stored within the data directory, so no files are written to the system's roaming profile.
|
||||
* `trilium-safe-mode`: Boots Trilium in "safe mode," disabling any startup scripts that might cause the application to crash.
|
||||
|
||||
## Synchronization
|
||||
|
||||
Reference in New Issue
Block a user