From 9577d6665ff370b6123a591873f41b0d167d15e3 Mon Sep 17 00:00:00 2001 From: SamTV12345 Date: Mon, 9 Sep 2024 07:58:08 +0200 Subject: [PATCH 1/2] Fixed v4 ueberdb --- databases/rusty_db.ts | 14 +++++++++++--- databases/sqlite_db.ts | 17 ++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/databases/rusty_db.ts b/databases/rusty_db.ts index 1d2c2533..56a3dcf9 100644 --- a/databases/rusty_db.ts +++ b/databases/rusty_db.ts @@ -1,8 +1,7 @@ import AbstractDatabase from "../lib/AbstractDatabase"; -import {KeyValueDB} from 'rusty-store-kv' export default class Rusty_db extends AbstractDatabase { - db: KeyValueDB |null| undefined + db: any |null| undefined constructor(settings: {filename: string}) { super(settings); @@ -34,7 +33,16 @@ export default class Rusty_db extends AbstractDatabase { } async init() { - this.db = new KeyValueDB(this.settings.filename!); + let RUSTY_DB + try { + RUSTY_DB = await import('rusty-store-kv'); + } catch (err) { + throw new Error( + 'rusty-store-kv not found. It was removed from ueberdb\'s dependencies because it requires ' + + 'compilation which fails on several systems. If you still want to use rusty store kv, run ' + + '"pnpm install rusty-store-kv" in your etherpad-lite ./src directory.'); + } + this.db = new RUSTY_DB.KeyValueDB(this.settings.filename!); } close() { diff --git a/databases/sqlite_db.ts b/databases/sqlite_db.ts index 95261990..a0841bde 100644 --- a/databases/sqlite_db.ts +++ b/databases/sqlite_db.ts @@ -19,12 +19,6 @@ import {SQLite} from 'rusty-store-kv' * limitations under the License. */ -const escape = (val:string) => `'${val.replace(/'/g, "''")}'`; - -type RequestVal = { - value: string; -} - export default class SQLiteDB extends AbstractDatabase { public db: SQLite|null; constructor(settings:Settings) { @@ -50,7 +44,16 @@ export default class SQLiteDB extends AbstractDatabase { } init(callback: Function) { - this.db = new SQLite(this.settings.filename as string) + let SQLITEDB + try { + SQLITEDB = require('rusty-store-kv'); + } catch (err) { + throw new Error( + 'rusty-store-kv not found. It was removed from ueberdb\'s dependencies because it requires ' + + 'compilation which fails on several systems. If you still want to use sqlite, run ' + + '"pnpm install rusty-store-kv" in your etherpad-lite ./src directory.'); + } + this.db = new SQLITEDB.SQLite(this.settings.filename as string) callback(); } From 599539d1f9ba0e5b388402af1a8e6156e7d8b51c Mon Sep 17 00:00:00 2001 From: SamTV12345 Date: Mon, 9 Sep 2024 08:00:54 +0200 Subject: [PATCH 2/2] Fixed module not found --- databases/sqlite_db.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/databases/sqlite_db.ts b/databases/sqlite_db.ts index a0841bde..5b25ab8e 100644 --- a/databases/sqlite_db.ts +++ b/databases/sqlite_db.ts @@ -1,7 +1,6 @@ 'use strict'; import {BulkObject} from "./cassandra_db"; import AbstractDatabase, {Settings} from "../lib/AbstractDatabase"; -import {SQLite} from 'rusty-store-kv' /** * 2011 Peter 'Pita' Martischka @@ -20,7 +19,7 @@ import {SQLite} from 'rusty-store-kv' */ export default class SQLiteDB extends AbstractDatabase { - public db: SQLite|null; + public db: any|null; constructor(settings:Settings) { super(settings); this.db = null;