mirror of
https://github.com/immich-app/immich.git
synced 2026-07-07 13:07:04 -07:00
review suggestion
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user