404 fix attempt 2
This commit is contained in:
@@ -14,10 +14,11 @@ export function getDb(): Database.Database {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
|
||||
_db = new Database(DB_PATH);
|
||||
_db.pragma('journal_mode = WAL');
|
||||
_db.pragma('foreign_keys = ON');
|
||||
initSchema(_db);
|
||||
const db = new Database(DB_PATH);
|
||||
db.pragma('journal_mode = WAL');
|
||||
db.pragma('foreign_keys = ON');
|
||||
initSchema(db);
|
||||
_db = db;
|
||||
return _db;
|
||||
}
|
||||
|
||||
@@ -81,7 +82,7 @@ function initSchema(db: Database.Database): void {
|
||||
const cols = db.prepare('PRAGMA table_info(games)').all() as Array<{ name: string }>;
|
||||
if (!cols.some((c) => c.name === 'series_id')) {
|
||||
db.exec(
|
||||
'ALTER TABLE games ADD COLUMN series_id INTEGER REFERENCES series(id) ON DELETE SET NULL'
|
||||
'ALTER TABLE games ADD COLUMN series_id INTEGER DEFAULT NULL REFERENCES series(id) ON DELETE SET NULL'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import type { LayoutServerLoad } from './$types';
|
||||
import { getDb } from '$lib/server/db';
|
||||
import { scanLibraries } from '$lib/server/scanner';
|
||||
import { getSession } from '$lib/server/auth';
|
||||
|
||||
export const load: LayoutServerLoad = ({ cookies }) => {
|
||||
const db = getDb();
|
||||
scanLibraries(db);
|
||||
return { loggedIn: getSession(cookies) };
|
||||
};
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { getDb } from '$lib/server/db';
|
||||
import { scanLibraries } from '$lib/server/scanner';
|
||||
|
||||
export const load: PageServerLoad = async ({ parent }) => {
|
||||
const { loggedIn } = await parent();
|
||||
const db = getDb();
|
||||
scanLibraries(db);
|
||||
|
||||
const games = loggedIn
|
||||
? db
|
||||
|
||||
Reference in New Issue
Block a user