From c8e6be5a97559ed810c7026d3a436119734a0e02 Mon Sep 17 00:00:00 2001 From: stfrigerio Date: Thu, 6 Feb 2025 11:28:33 +0100 Subject: [PATCH] updated .config folder position --- src/dbService.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/dbService.ts b/src/dbService.ts index 8dfc33e..5e80570 100644 --- a/src/dbService.ts +++ b/src/dbService.ts @@ -1,4 +1,4 @@ -import { Notice, FileSystemAdapter } from "obsidian"; +import { Notice, App } from "obsidian"; import initSqlJs, { Database } from "sql.js"; import { readFileSync } from "fs"; import { SqliteDBSettings } from "./types"; @@ -8,6 +8,11 @@ import { SqliteDBSettings } from "./types"; */ export class DBService { private db: Database | null = null; + private app: App; + + constructor(app: App) { + this.app = app; + } /** * Ensure the DB is loaded. If it's not loaded yet, load it from disk. @@ -20,10 +25,11 @@ export class DBService { new Notice("No DB path set in plugin settings."); return; } + if (!this.db || forceReload) { try { const SQL = await initSqlJs({ - locateFile: (file) => `${basePath}/.obsidian/plugins/sqliteDB/${file}`, + locateFile: (file) => `${basePath}/${this.app.vault.configDir}/plugins/sqliteDB/${file}`, }); const fileBuffer = readFileSync(settings.dbFilePath); const uint8Array = new Uint8Array(fileBuffer);