This commit is contained in:
@@ -5,8 +5,6 @@ import { dirname, join, resolve } from 'node:path';
|
||||
import { db } from '../db/index.js';
|
||||
import { config } from '../config.js';
|
||||
import { getHost, getHostOperation, listHosts, queueHostOperation } from '../hosts/index.js';
|
||||
import { ensureGameFileSchema } from './schema.js';
|
||||
import { ensureHostSchema } from '../hosts/schema.js';
|
||||
import {
|
||||
manifestChecksum,
|
||||
receiveGameFile,
|
||||
@@ -35,10 +33,7 @@ import type {
|
||||
} from '../../game-files.js';
|
||||
|
||||
function database() {
|
||||
const handle = db();
|
||||
ensureGameFileSchema(handle);
|
||||
ensureHostSchema(handle);
|
||||
return handle;
|
||||
return db();
|
||||
}
|
||||
export const gameFilesRoot = () =>
|
||||
resolve(process.env.GAME_FILES_ROOT ?? join(dirname(config.dbPath), 'game-files'));
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
import type Database from 'better-sqlite3';
|
||||
|
||||
const initialized = new WeakSet<Database.Database>();
|
||||
export function ensureGameFileSchema(handle: Database.Database): void {
|
||||
if (initialized.has(handle)) return;
|
||||
// Worker readers open only after the controller has initialized the schema.
|
||||
if (handle.readonly) {
|
||||
initialized.add(handle);
|
||||
return;
|
||||
}
|
||||
export function migrateGameFileSchema(handle: Database.Database): void {
|
||||
handle.exec(`
|
||||
CREATE TABLE IF NOT EXISTS game_file_libraries (
|
||||
id TEXT PRIMARY KEY, name TEXT NOT NULL COLLATE NOCASE UNIQUE,
|
||||
@@ -62,5 +55,4 @@ export function ensureGameFileSchema(handle: Database.Database): void {
|
||||
handle.exec('ALTER TABLE host_library_caches ADD COLUMN bytes_verified INTEGER');
|
||||
if (!cacheColumns.some((column) => column.name === 'transfer_progress'))
|
||||
handle.exec('ALTER TABLE host_library_caches ADD COLUMN transfer_progress TEXT');
|
||||
initialized.add(handle);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user