This commit is contained in:
xadyz1 2026-07-26 13:04:18 +01:00
parent c9adb31882
commit 6cf86533e4
2 changed files with 12 additions and 2 deletions

View file

@ -343,4 +343,6 @@ module.exports = {
bunnyStorageEndpoint: process.env.VITE_BUNNY_STORAGE_ENDPOINT || '',
bunnyApiKey: process.env.VITE_BUNNY_API_KEY || '',
bunnyPullZone: process.env.VITE_BUNNY_PULL_ZONE || '',
bunnyDbUrl: process.env.BUNNY_DATABASE_URL || '',
bunnyDbAuthToken: process.env.BUNNY_DATABASE_AUTH_TOKEN || '',
};

View file

@ -1,4 +1,4 @@
const Database = require('better-sqlite3');
const Database = require('libsql');
const fs = require('fs');
const path = require('path');
const config = require('../config');
@ -7,7 +7,15 @@ const { chunkedDelete, yieldTick, currentBand } = require('../lib/chunked-prune'
const dbDir = path.dirname(config.dbPath);
if (!fs.existsSync(dbDir)) fs.mkdirSync(dbDir, { recursive: true });
const db = new Database(config.dbPath);
const dbOptions = {};
if (config.bunnyDbUrl && config.bunnyDbAuthToken) {
dbOptions.syncUrl = config.bunnyDbUrl;
dbOptions.authToken = config.bunnyDbAuthToken;
}
const db = new Database(config.dbPath, dbOptions);
if (dbOptions.syncUrl) {
db.sync(); // Initial sync
}
// Enable WAL mode and foreign keys
db.pragma('journal_mode = WAL');