@@ -9,6 +9,7 @@ import 'dart:typed_data';
99
1010import 'package:ffi/ffi.dart' ;
1111import 'package:meta/meta.dart' ;
12+ import 'package:objectbox/src/native/version.dart' ;
1213import 'package:path/path.dart' as path;
1314
1415import '../common.dart' ;
@@ -30,6 +31,10 @@ class Store {
3031 /// Path of the default directory, currently 'objectbox'.
3132 static const String defaultDirectoryPath = 'objectbox' ;
3233
34+ /// Enables a couple of debug logs.
35+ /// This meant for tests only; do not enable for releases!
36+ static bool debugLogs = false ;
37+
3338 late final Pointer <OBX_store > _cStore;
3439 HashMap <int , Type >? _entityTypeById;
3540 final _boxes = HashMap <Type , Box >();
@@ -130,6 +135,11 @@ class Store {
130135 C .opt_free (opt);
131136 rethrow ;
132137 }
138+ if (debugLogs) {
139+ print ('Opening store (C lib V${libraryVersion ()})... path=$directory '
140+ ' isOpen=${isOpen (directory )}' );
141+ }
142+
133143 _cStore = C .store_open (opt);
134144
135145 _checkStorePointer (_cStore);
@@ -233,12 +243,17 @@ class Store {
233243 final path = _safeDirectoryPath (directoryPath);
234244 final pathCStr = path.toNativeUtf8 ();
235245 try {
246+ if (debugLogs) {
247+ final isOpen = C .store_is_open (pathCStr.cast ());
248+ print ('Attaching to store... path=$path isOpen=$isOpen ' );
249+ }
236250 _cStore = C .store_attach (pathCStr.cast ());
237251 } finally {
238252 malloc.free (pathCStr);
239253 }
240254
241- _checkStorePointer (_cStore);
255+ checkObxPtr (_cStore,
256+ 'could not attach to the store at given path - please ensure it was opened before' );
242257
243258 // Not setting _reference as this is a replacement for obtaining a store
244259 // via reference.
0 commit comments