diff --git a/electron/src/rt/sqlite-init.ts b/electron/src/rt/sqlite-init.ts index e2525f2e..36e8eb20 100644 --- a/electron/src/rt/sqlite-init.ts +++ b/electron/src/rt/sqlite-init.ts @@ -680,20 +680,22 @@ export function setupSQLiteHandlers(): void { throw new Error('Database path not initialized'); } - // Use same connection options format + // Clean up connection options to be consistent const connectionOptions = { - ...options, database: 'timesafari', // Base name only - readOnly: false, - mode: 'rwc', + version: 1, + readOnly: false, // Single source of truth for read-only state + mode: 'rwc', // Force read-write-create mode encryption: 'no-encryption', useNative: true, - location: 'default' // Let plugin handle path resolution + location: 'default' // Let plugin handle path resolution }; + // Log the actual options being used logger.info('Creating database connection with options:', { ...connectionOptions, - expectedBehavior: 'Plugin will append SQLite suffix and handle path resolution' + expectedBehavior: 'Plugin will append SQLite suffix and handle path resolution', + actualPath: path.join(dbDir, 'timesafariSQLite.db') }); // Create connection (returns undefined but registers internally) @@ -709,18 +711,21 @@ export function setupSQLiteHandlers(): void { debugLog('Connection registration check:', { isRegistered, - database: connectionOptions.database + database: connectionOptions.database, + actualPath: path.join(dbDir, 'timesafariSQLite.db') }); if (!isRegistered) { throw new Error('Database not registered after createConnection'); } - // Return success object instead of undefined + // Return success object with more details return { success: true, database: connectionOptions.database, - isRegistered: true + isRegistered: true, + actualPath: path.join(dbDir, 'timesafariSQLite.db'), + options: connectionOptions }; } catch (error) { logger.error('Error in sqlite-create-connection:', error);