diff --git a/src/backend/src/services/database/SqliteDatabaseAccessService.js b/src/backend/src/services/database/SqliteDatabaseAccessService.js index 5458cbf3..2c6470b4 100644 --- a/src/backend/src/services/database/SqliteDatabaseAccessService.js +++ b/src/backend/src/services/database/SqliteDatabaseAccessService.js @@ -44,21 +44,6 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService { this.db = new Database(this.config.path); - // Database upgrade logic - const HIGHEST_VERSION = 24; - const TARGET_VERSION = (() => { - const args = Context.get('args'); - if ( args['database-target-version'] ) { - return parseInt(args['database-target-version']); - } - return HIGHEST_VERSION; - })(); - - const [{ user_version }] = do_setup - ? [{ user_version: -1 }] - : await this._read('PRAGMA user_version'); - this.log.info('database version: ' + user_version); - const upgrade_files = []; const available_migrations = [ @@ -138,8 +123,28 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService { [23, [ '0026_user-groups.dbmig.js', ]], + [24, [ + '0027_emulator-app.dbmig.js', + ]], ]; + // Database upgrade logic + const HIGHEST_VERSION = + available_migrations[available_migrations.length - 1][0] + 1; + const TARGET_VERSION = (() => { + const args = Context.get('args'); + if ( args['database-target-version'] ) { + return parseInt(args['database-target-version']); + } + return HIGHEST_VERSION; + })(); + + const [{ user_version }] = do_setup + ? [{ user_version: -1 }] + : await this._read('PRAGMA user_version'); + this.log.info('database version: ' + user_version); + + for ( const [v_lt_or_eq, files] of available_migrations ) { if ( v_lt_or_eq + 1 >= TARGET_VERSION && TARGET_VERSION !== HIGHEST_VERSION ) { this.log.noticeme(`Early exit: target version set to ${TARGET_VERSION}`); diff --git a/src/backend/src/services/database/sqlite_setup/0027_emulator-app.dbmig.js b/src/backend/src/services/database/sqlite_setup/0027_emulator-app.dbmig.js new file mode 100644 index 00000000..0e3b5ad1 --- /dev/null +++ b/src/backend/src/services/database/sqlite_setup/0027_emulator-app.dbmig.js @@ -0,0 +1,23 @@ +const insert = async (tbl, subject) => { + const keys = Object.keys(subject); + + await write( + 'INSERT INTO `'+ tbl +'` ' + + '(' + keys.map(key => key).join(', ') + ') ' + + 'VALUES (' + keys.map(() => '?').join(', ') + ')', + keys.map(key => subject[key]) + ); +} + +await insert('apps', { + uid: 'app-fbbdb72b-ad08-4cb4-86a1-de0f27cf2e1e', + owner_user_id: 1, + name: 'puter-linux', + index_url: 'https://builtins.namespaces.puter.com/emulator', + title: 'Puter Linux', + description: 'Linux emulator for Puter', + approved_for_listing: 1, + approved_for_opening_items: 1, + approved_for_incentive_program: 0, + timestamp: '2020-01-01 00:00:00', +}); diff --git a/src/gui/src/services/ExecService.js b/src/gui/src/services/ExecService.js index 5fcad6ed..ed6813a7 100644 --- a/src/gui/src/services/ExecService.js +++ b/src/gui/src/services/ExecService.js @@ -100,7 +100,7 @@ export class ExecService extends Service { if ( caller_process.name !== 'phoenix' ) { throw new Error('Connection not allowed.'); } - if ( app_name !== 'test-emu' ) { + if ( app_name !== 'puter-linux' ) { throw new Error('Connection not allowed.'); } diff --git a/src/gui/src/services/ProcessService.js b/src/gui/src/services/ProcessService.js index d41404ee..a6ac38a6 100644 --- a/src/gui/src/services/ProcessService.js +++ b/src/gui/src/services/ProcessService.js @@ -23,7 +23,7 @@ const NULL_UUID = '00000000-0000-0000-0000-000000000000'; export class ProcessService extends Service { static INITRC = [ - 'test-emu' + 'puter-linux' ]; async _init () { diff --git a/src/phoenix/src/puter-shell/providers/EmuCommandProvider.js b/src/phoenix/src/puter-shell/providers/EmuCommandProvider.js index 4fbdade8..81f90cea 100644 --- a/src/phoenix/src/puter-shell/providers/EmuCommandProvider.js +++ b/src/phoenix/src/puter-shell/providers/EmuCommandProvider.js @@ -8,7 +8,7 @@ export class EmuCommandProvider { 'emu-sort': '/usr/bin/sort', }; - static EMU_APP_NAME = 'test-emu'; + static EMU_APP_NAME = 'puter-linux'; constructor () { this.available = this.constructor.AVAILABLE;