mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 03:16:11 +01:00
Merge branch 'develop' into feature/MFA
This commit is contained in:
@@ -2,7 +2,7 @@ import log from "./log.js";
|
||||
import fs from "fs";
|
||||
import resourceDir from "./resource_dir.js";
|
||||
import sql from "./sql.js";
|
||||
import utils from "./utils.js";
|
||||
import { isElectron, deferred } from "./utils.js";
|
||||
import optionService from "./options.js";
|
||||
import port from "./port.js";
|
||||
import BOption from "../becca/entities/boption.js";
|
||||
@@ -10,7 +10,7 @@ import TaskContext from "./task_context.js";
|
||||
import migrationService from "./migration.js";
|
||||
import cls from "./cls.js";
|
||||
import config from "./config.js";
|
||||
import { OptionRow } from '../becca/entities/rows.js';
|
||||
import type { OptionRow } from "../becca/entities/rows.js";
|
||||
import BNote from "../becca/entities/bnote.js";
|
||||
import BBranch from "../becca/entities/bbranch.js";
|
||||
import zipImportService from "./import/zip.js";
|
||||
@@ -18,7 +18,7 @@ import becca_loader from "../becca/becca_loader.js";
|
||||
import password from "./encryption/password.js";
|
||||
import backup from "./backup.js";
|
||||
|
||||
const dbReady = utils.deferred<void>();
|
||||
const dbReady = deferred<void>();
|
||||
|
||||
function schemaExists() {
|
||||
return !!sql.getValue(`SELECT name FROM sqlite_master
|
||||
@@ -32,13 +32,12 @@ function isDbInitialized() {
|
||||
|
||||
const initialized = sql.getValue("SELECT value FROM options WHERE name = 'initialized'");
|
||||
|
||||
return initialized === 'true';
|
||||
return initialized === "true";
|
||||
}
|
||||
|
||||
async function initDbConnection() {
|
||||
if (!isDbInitialized()) {
|
||||
log.info(`DB not initialized, please visit setup page` +
|
||||
(utils.isElectron() ? '' : ` - http://[your-server-host]:${port} to see instructions on how to initialize Trilium.`));
|
||||
log.info(`DB not initialized, please visit setup page` + (isElectron ? "" : ` - http://[your-server-host]:${port} to see instructions on how to initialize Trilium.`));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -88,17 +87,17 @@ async function createInitialDatabase() {
|
||||
log.info("Creating root note ...");
|
||||
|
||||
rootNote = new BNote({
|
||||
noteId: 'root',
|
||||
title: 'root',
|
||||
type: 'text',
|
||||
mime: 'text/html'
|
||||
noteId: "root",
|
||||
title: "root",
|
||||
type: "text",
|
||||
mime: "text/html"
|
||||
}).save();
|
||||
|
||||
rootNote.setContent('');
|
||||
rootNote.setContent("");
|
||||
|
||||
new BBranch({
|
||||
noteId: 'root',
|
||||
parentNoteId: 'none',
|
||||
noteId: "root",
|
||||
parentNoteId: "none",
|
||||
isExpanded: true,
|
||||
notePosition: 10
|
||||
}).save();
|
||||
@@ -111,7 +110,7 @@ async function createInitialDatabase() {
|
||||
|
||||
log.info("Importing demo content ...");
|
||||
|
||||
const dummyTaskContext = new TaskContext("no-progress-reporting", 'import', false);
|
||||
const dummyTaskContext = new TaskContext("no-progress-reporting", "import", false);
|
||||
|
||||
await zipImportService.importZip(dummyTaskContext, demoFile, rootNote);
|
||||
|
||||
@@ -122,12 +121,15 @@ async function createInitialDatabase() {
|
||||
|
||||
const startNoteId = sql.getValue("SELECT noteId FROM branches WHERE parentNoteId = 'root' AND isDeleted = 0 ORDER BY notePosition");
|
||||
|
||||
optionService.setOption('openNoteContexts', JSON.stringify([
|
||||
{
|
||||
notePath: startNoteId,
|
||||
active: true
|
||||
}
|
||||
]));
|
||||
optionService.setOption(
|
||||
"openNoteContexts",
|
||||
JSON.stringify([
|
||||
{
|
||||
notePath: startNoteId,
|
||||
active: true
|
||||
}
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
log.info("Schema and initial content generated.");
|
||||
@@ -135,7 +137,7 @@ async function createInitialDatabase() {
|
||||
initDbConnection();
|
||||
}
|
||||
|
||||
async function createDatabaseForSync(options: OptionRow[], syncServerHost = '', syncProxy = '') {
|
||||
async function createDatabaseForSync(options: OptionRow[], syncServerHost = "", syncProxy = "") {
|
||||
log.info("Creating database for sync");
|
||||
|
||||
if (isDbInitialized()) {
|
||||
@@ -163,7 +165,7 @@ async function createDatabaseForSync(options: OptionRow[], syncServerHost = '',
|
||||
|
||||
function setDbAsInitialized() {
|
||||
if (!isDbInitialized()) {
|
||||
optionService.setOption('initialized', 'true');
|
||||
optionService.setOption("initialized", "true");
|
||||
|
||||
initDbConnection();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user