Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add busy timeout to SQLite connections to prevent errors (#389)

Leendert de Borste9064643a62f
diff --git a/src/Databases/AliasServerDb/AliasServerDbContext.cs b/src/Databases/AliasServerDb/AliasServerDbContext.cs
index 6e4a7e27b..3d054f7ca 100644
--- a/src/Databases/AliasServerDb/AliasServerDbContext.cs
+++ b/src/Databases/AliasServerDb/AliasServerDbContext.cs
@@ -248,6 +248,19 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyCon
optionsBuilder
.UseSqlite(configuration.GetConnectionString("AliasServerDbContext"))
.UseLazyLoadingProxies();
+
+ // Set busy timeout using PRAGMA to avoid "The database file is locked" error.
+ var connection = Database.GetDbConnection();
+ if (connection.State != System.Data.ConnectionState.Open)
+ {
+ connection.Open();
+ }
+
+ using (var command = connection.CreateCommand())
+ {
+ command.CommandText = "PRAGMA busy_timeout = 5000;";
+ command.ExecuteNonQuery();
+ }
}
}
}