@@ -237,34 +237,23 @@ class LocalDbBridge extends LocalSbRequestImpl {
237237
238238 Future <void > _init (String dbName) async {
239239 try {
240- log ('=== DEBUG: Attempting to create database with path: $dbName ' );
240+ log ('Attempting to create database with path: $dbName ' );
241241
242- // Test different path formats to understand what Rust expects
243- final testPaths = [
244- dbName,
245- '$dbName .db' ,
246- '$dbName .lmdb' ,
247- '/tmp/test_db' ,
248- 'test_simple'
249- ];
242+ // Rust expects the path to end with .lmdb
243+ final lmdbPath = '$dbName .lmdb' ;
244+ final dbNamePointer = lmdbPath.toNativeUtf8 ();
245+ _dbInstance = _createDatabase (dbNamePointer);
250246
251- for (final testPath in testPaths) {
252- log ('Testing path: $testPath ' );
253- final pathPointer = testPath.toNativeUtf8 ();
254- final testInstance = _createDatabase (pathPointer);
255- log ('Result for $testPath : ${testInstance == nullptr ? "NULL" : "SUCCESS" }' );
256- calloc.free (pathPointer);
257-
258- if (testInstance != nullptr) {
259- _dbInstance = testInstance;
260- _hotRestartDetected = false ;
261- log ('Database created successfully with path: $testPath ' );
262- return ;
263- }
247+ if (_dbInstance == nullptr) {
248+ calloc.free (dbNamePointer);
249+ throw Exception ('Failed to create database instance. Returned null pointer.' );
264250 }
265-
266- throw Exception ('All path formats failed. Rust create_db consistently returns null.' );
267251
252+ // Reset hot restart flag on successful initialization
253+ _hotRestartDetected = false ;
254+ log ('Database instance created successfully: ${_dbInstance .toString ()}' );
255+
256+ calloc.free (dbNamePointer);
268257 } catch (error, stackTrace) {
269258 log ('Error in _init: $error ' );
270259 log ('Stack trace: $stackTrace ' );
0 commit comments