Skip to content

Commit e1e6e04

Browse files
committed
now with lmdb base ug
1 parent 0298603 commit e1e6e04

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

lib/src/bridge/local_db_bridge.dart

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,17 @@ class LocalDbBridge extends LocalSbRequestImpl {
113113
log('Functions bound successfully');
114114

115115
/// Define default route.
116-
final appDir = await getApplicationDocumentsDirectory();
117-
log('Using app directory: ${appDir.path}');
116+
Directory appDir;
117+
try {
118+
// Usar Application Documents Directory como estándar
119+
appDir = await getApplicationDocumentsDirectory();
120+
log('Using Application Documents Directory: ${appDir.path}');
121+
} catch (e) {
122+
// Fallback a Application Support Directory si falla el Documents
123+
log('Application Documents Directory failed: $e');
124+
appDir = await getApplicationSupportDirectory();
125+
log('Using Application Support Directory fallback: ${appDir.path}');
126+
}
118127

119128
/// Initialize database with default route and database name.
120129
// Ensure database name doesn't have extension, Rust expects .lmdb
@@ -164,7 +173,12 @@ class LocalDbBridge extends LocalSbRequestImpl {
164173
_dbInstance = null;
165174

166175
// Reinicializar solo la instancia de base de datos
167-
final appDir = await getApplicationDocumentsDirectory();
176+
Directory appDir;
177+
try {
178+
appDir = await getApplicationDocumentsDirectory();
179+
} catch (e) {
180+
appDir = await getApplicationSupportDirectory();
181+
}
168182
final dbBaseName = _lastDatabaseName!.replaceAll('.db', '');
169183
await _init('${appDir.path}/$dbBaseName');
170184
log('Database connection reestablished successfully');

0 commit comments

Comments
 (0)