From 2427addf658f4243c3a7b89be20f1f9d2a9be5f8 Mon Sep 17 00:00:00 2001 From: FliegendeWurst Date: Wed, 21 May 2025 17:24:00 +0200 Subject: [PATCH] feat(server): override options for read-only database --- apps/server/src/routes/api/options.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/server/src/routes/api/options.ts b/apps/server/src/routes/api/options.ts index a31206404..3a0a9b06b 100644 --- a/apps/server/src/routes/api/options.ts +++ b/apps/server/src/routes/api/options.ts @@ -7,6 +7,7 @@ import ValidationError from "../../errors/validation_error.js"; import type { Request } from "express"; import { changeLanguage, getLocales } from "../../services/i18n.js"; import type { OptionNames } from "@triliumnext/commons"; +import config from "../../services/config.js"; // options allowed to be updated directly in the Options dialog const ALLOWED_OPTIONS = new Set([ @@ -127,6 +128,12 @@ function getOptions() { } resultMap["isPasswordSet"] = optionMap["passwordVerificationHash"] ? "true" : "false"; + // if database is read-only, disable editing in UI by setting 0 here + if (config.General.readOnly) { + resultMap["autoReadonlySizeText"] = "0"; + resultMap["autoReadonlySizeCode"] = "0"; + resultMap["databaseReadonly"] = "true"; + } return resultMap; }