mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	server: Fix init database not working due to share db
This commit is contained in:
		| @@ -2,8 +2,12 @@ | |||||||
|  |  | ||||||
| import Database from "better-sqlite3"; | import Database from "better-sqlite3"; | ||||||
| import dataDir from "../services/data_dir.js"; | import dataDir from "../services/data_dir.js"; | ||||||
|  | import sql_init from "../services/sql_init.js"; | ||||||
|  |  | ||||||
| const dbConnection = new Database(dataDir.DOCUMENT_PATH, { readonly: true }); | let dbConnection!: Database.Database; | ||||||
|  |  | ||||||
|  | sql_init.dbReady.then(() => { | ||||||
|  |     dbConnection = new Database(dataDir.DOCUMENT_PATH, { readonly: true }); | ||||||
|      |      | ||||||
|     [`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `SIGTERM`].forEach(eventType => { |     [`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `SIGTERM`].forEach(eventType => { | ||||||
|         process.on(eventType, () => { |         process.on(eventType, () => { | ||||||
| @@ -14,6 +18,7 @@ const dbConnection = new Database(dataDir.DOCUMENT_PATH, { readonly: true }); | |||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|     }); |     }); | ||||||
|  | }); | ||||||
|  |  | ||||||
| function getRawRows<T>(query: string, params = []): T[] { | function getRawRows<T>(query: string, params = []): T[] { | ||||||
|     return dbConnection.prepare(query).raw().all(params) as T[]; |     return dbConnection.prepare(query).raw().all(params) as T[]; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user