mirror of
https://github.com/zadam/trilium.git
synced 2025-11-06 13:26:01 +01:00
Merge branch 'main' into feat/rice-searching-with-sqlite
This commit is contained in:
@@ -17,6 +17,8 @@ import zipImportService from "./import/zip.js";
|
||||
import password from "./encryption/password.js";
|
||||
import backup from "./backup.js";
|
||||
import eventService from "./events.js";
|
||||
import { t } from "i18next";
|
||||
import hidden_subtree from "./hidden_subtree.js";
|
||||
|
||||
export const dbReady = deferred<void>();
|
||||
|
||||
@@ -37,7 +39,11 @@ function isDbInitialized() {
|
||||
|
||||
async function initDbConnection() {
|
||||
if (!isDbInitialized()) {
|
||||
log.info(`DB not initialized, please visit setup page` + (isElectron ? "" : ` - http://[your-server-host]:${port} to see instructions on how to initialize Trilium.`));
|
||||
if (isElectron) {
|
||||
log.info(t("sql_init.db_not_initialized_desktop"));
|
||||
} else {
|
||||
log.info(t("sql_init.db_not_initialized_server", { port }));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -130,14 +136,21 @@ async function createInitialDatabase(skipDemoDb?: boolean) {
|
||||
password.resetPassword();
|
||||
});
|
||||
|
||||
log.info("Importing demo content ...");
|
||||
// Check hidden subtree.
|
||||
// This ensures the existence of system templates, for the demo content.
|
||||
console.log("Checking hidden subtree at first start.");
|
||||
cls.init(() => hidden_subtree.checkHiddenSubtree());
|
||||
|
||||
const dummyTaskContext = new TaskContext("no-progress-reporting", "import", false);
|
||||
// Import demo content.
|
||||
log.info("Importing demo content...");
|
||||
|
||||
const dummyTaskContext = new TaskContext("no-progress-reporting", "importNotes", null);
|
||||
|
||||
if (demoFile) {
|
||||
await zipImportService.importZip(dummyTaskContext, demoFile, rootNote);
|
||||
}
|
||||
|
||||
// Post-demo.
|
||||
sql.transactional(() => {
|
||||
// this needs to happen after ZIP import,
|
||||
// the previous solution was to move option initialization here, but then the important parts of initialization
|
||||
@@ -212,15 +225,13 @@ function optimize() {
|
||||
log.info(`Optimization finished in ${Date.now() - start}ms.`);
|
||||
}
|
||||
|
||||
function getDbSize() {
|
||||
export function getDbSize() {
|
||||
return sql.getValue<number>("SELECT page_count * page_size / 1000 as size FROM pragma_page_count(), pragma_page_size()");
|
||||
}
|
||||
|
||||
function initializeDb() {
|
||||
cls.init(initDbConnection);
|
||||
|
||||
log.info(`DB size: ${getDbSize()} KB`);
|
||||
|
||||
dbReady.then(() => {
|
||||
if (config.General && config.General.noBackup === true) {
|
||||
log.info("Disabling scheduled backups.");
|
||||
|
||||
Reference in New Issue
Block a user