mirror of
https://github.com/zadam/trilium.git
synced 2025-11-04 13:39:01 +01:00
feat(server): add option to mount database read-only
This commit is contained in:
parent
8ffe44de8a
commit
fd0f0196cc
@ -21,6 +21,7 @@ export interface TriliumConfig {
|
|||||||
noAuthentication: boolean;
|
noAuthentication: boolean;
|
||||||
noBackup: boolean;
|
noBackup: boolean;
|
||||||
noDesktopIcon: boolean;
|
noDesktopIcon: boolean;
|
||||||
|
readOnly: boolean;
|
||||||
};
|
};
|
||||||
Network: {
|
Network: {
|
||||||
host: string;
|
host: string;
|
||||||
@ -62,7 +63,10 @@ const config: TriliumConfig = {
|
|||||||
envToBoolean(process.env.TRILIUM_GENERAL_NOBACKUP) || iniConfig.General.noBackup || false,
|
envToBoolean(process.env.TRILIUM_GENERAL_NOBACKUP) || iniConfig.General.noBackup || false,
|
||||||
|
|
||||||
noDesktopIcon:
|
noDesktopIcon:
|
||||||
envToBoolean(process.env.TRILIUM_GENERAL_NODESKTOPICON) || iniConfig.General.noDesktopIcon || false
|
envToBoolean(process.env.TRILIUM_GENERAL_NODESKTOPICON) || iniConfig.General.noDesktopIcon || false,
|
||||||
|
|
||||||
|
readOnly:
|
||||||
|
envToBoolean(process.env.TRILIUM_GENERAL_READONLY) || iniConfig.General.readOnly || false
|
||||||
},
|
},
|
||||||
|
|
||||||
Network: {
|
Network: {
|
||||||
|
|||||||
@ -13,18 +13,20 @@ import Database from "better-sqlite3";
|
|||||||
import ws from "./ws.js";
|
import ws from "./ws.js";
|
||||||
import becca_loader from "../becca/becca_loader.js";
|
import becca_loader from "../becca/becca_loader.js";
|
||||||
import entity_changes from "./entity_changes.js";
|
import entity_changes from "./entity_changes.js";
|
||||||
|
import config from "./config.js";
|
||||||
|
|
||||||
let dbConnection: DatabaseType = buildDatabase();
|
let dbConnection: DatabaseType = buildDatabase();
|
||||||
let statementCache: Record<string, Statement> = {};
|
let statementCache: Record<string, Statement> = {};
|
||||||
|
|
||||||
function buildDatabase() {
|
function buildDatabase() {
|
||||||
|
// for integration tests, ignore the config's readOnly setting
|
||||||
if (process.env.TRILIUM_INTEGRATION_TEST === "memory") {
|
if (process.env.TRILIUM_INTEGRATION_TEST === "memory") {
|
||||||
return buildIntegrationTestDatabase();
|
return buildIntegrationTestDatabase();
|
||||||
} else if (process.env.TRILIUM_INTEGRATION_TEST === "memory-no-store") {
|
} else if (process.env.TRILIUM_INTEGRATION_TEST === "memory-no-store") {
|
||||||
return new Database(":memory:");
|
return new Database(":memory:");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Database(dataDir.DOCUMENT_PATH);
|
return new Database(dataDir.DOCUMENT_PATH, { readonly: config.General.readOnly });
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildIntegrationTestDatabase(dbPath?: string) {
|
function buildIntegrationTestDatabase(dbPath?: string) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user