review suggestion

This commit is contained in:
shenlong-tanwen
2026-07-07 20:20:29 +05:30
parent 3ee4a2936a
commit 133e7d3e35
2 changed files with 13 additions and 11 deletions
@@ -365,12 +365,11 @@ final class _DriftPoolStreamQueries extends StreamQueryStore {
Future<void> deleteSqliteDatabase({required String name}) async {
final file = await _databaseFile(name);
for (final path in [file.path, '${file.path}-wal', '${file.path}-shm']) {
final sidecar = File(path);
if (await sidecar.exists()) {
await sidecar.delete();
}
}
await [
file.path,
'${file.path}-wal',
'${file.path}-shm',
].map((path) => File(path).delete().catchError((_) => File(path), test: (e) => e is PathNotFoundException)).wait;
}
Future<SqliteConnection> openSqliteConnection({required String name}) async {
+8 -5
View File
@@ -74,13 +74,16 @@ Future<DriftLogger> _openLogDb() async {
final logDb = await open();
try {
await logDb.customSelect('SELECT COUNT(*) FROM logger_messages').get();
return logDb;
} on SqliteException catch (error) {
if (error.resultCode == 11 || error.resultCode == 26) {
dPrint(() => 'Logs database is unusable, recreating it');
if (error.resultCode != SqlError.SQLITE_CORRUPT && error.resultCode != SqlError.SQLITE_NOTADB) {
await logDb.close();
await deleteSqliteDatabase(name: 'immich_logs');
return open();
rethrow;
}
dPrint(() => 'Logs database is corrupt, recreating it');
await logDb.close();
await deleteSqliteDatabase(name: 'immich_logs');
return open();
}
return logDb;
}