Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Cap sqlite_async reader pools for low-traffic databases

laurenspriemf40da110ae85
diff --git a/mobile/apps/photos/lib/db/common/base.dart b/mobile/apps/photos/lib/db/common/base.dart
index 01436b793b..99cee78bcb 100644
--- a/mobile/apps/photos/lib/db/common/base.dart
+++ b/mobile/apps/photos/lib/db/common/base.dart
@@ -38,12 +38,13 @@ mixin SqlDbBase {
Future<SqliteDatabase> openMigratedDatabase(
String dbName,
List<String> migrationScripts, {
+ int maxReaders = 1,
void Function(String path)? logPath,
}) async {
final documentsDirectory = await getApplicationDocumentsDirectory();
final String path = join(documentsDirectory.path, dbName);
logPath?.call(path);
- final database = SqliteDatabase(path: path);
+ final database = SqliteDatabase(path: path, maxReaders: maxReaders);
try {
await migrate(database, migrationScripts);
return database;
diff --git a/mobile/apps/photos/lib/db/files_db.dart b/mobile/apps/photos/lib/db/files_db.dart
index e1992f12ea..835f4951f7 100644
--- a/mobile/apps/photos/lib/db/files_db.dart
+++ b/mobile/apps/photos/lib/db/files_db.dart
@@ -130,6 +130,7 @@ class FilesDB with SqlDbBase {
() => openMigratedDatabase(
_databaseName,
_migrationScripts,
+ maxReaders: 5,
logPath: (path) => _logger.info("DB path " + path),
),
);
diff --git a/mobile/packages/contacts/lib/src/db/contacts_database.dart b/mobile/packages/contacts/lib/src/db/contacts_database.dart
index 73ac5808b8..820463cfaf 100644
--- a/mobile/packages/contacts/lib/src/db/contacts_database.dart
+++ b/mobile/packages/contacts/lib/src/db/contacts_database.dart
@@ -220,7 +220,7 @@ class ContactsDatabase {
'$_databasePrefix$userId$_databaseSuffix',
);
- final database = SqliteDatabase(path: path);
+ final database = SqliteDatabase(path: path, maxReaders: 1);
try {
await _migrate(database);
return database;