@@ -9,6 +9,7 @@ import 'dart:typed_data';
9
9
10
10
import 'package:ffi/ffi.dart' ;
11
11
import 'package:meta/meta.dart' ;
12
+ import 'package:objectbox/src/native/version.dart' ;
12
13
import 'package:path/path.dart' as path;
13
14
14
15
import '../common.dart' ;
@@ -30,6 +31,10 @@ class Store {
30
31
/// Path of the default directory, currently 'objectbox'.
31
32
static const String defaultDirectoryPath = 'objectbox' ;
32
33
34
+ /// Enables a couple of debug logs.
35
+ /// This meant for tests only; do not enable for releases!
36
+ static bool debugLogs = false ;
37
+
33
38
late final Pointer <OBX_store > _cStore;
34
39
HashMap <int , Type >? _entityTypeById;
35
40
final _boxes = HashMap <Type , Box >();
@@ -130,6 +135,11 @@ class Store {
130
135
C .opt_free (opt);
131
136
rethrow ;
132
137
}
138
+ if (debugLogs) {
139
+ print ('Opening store (C lib V${libraryVersion ()})... path=$directory '
140
+ ' isOpen=${isOpen (directory )}' );
141
+ }
142
+
133
143
_cStore = C .store_open (opt);
134
144
135
145
_checkStorePointer (_cStore);
@@ -233,12 +243,17 @@ class Store {
233
243
final path = _safeDirectoryPath (directoryPath);
234
244
final pathCStr = path.toNativeUtf8 ();
235
245
try {
246
+ if (debugLogs) {
247
+ final isOpen = C .store_is_open (pathCStr.cast ());
248
+ print ('Attaching to store... path=$path isOpen=$isOpen ' );
249
+ }
236
250
_cStore = C .store_attach (pathCStr.cast ());
237
251
} finally {
238
252
malloc.free (pathCStr);
239
253
}
240
254
241
- _checkStorePointer (_cStore);
255
+ checkObxPtr (_cStore,
256
+ 'could not attach to the store at given path - please ensure it was opened before' );
242
257
243
258
// Not setting reference as this is a replacement for obtaining a store
244
259
// via reference.
0 commit comments