rdt-client/server/RdtClient.Data/DiConfig.cs
omgbeez faf43a2202
fix: Disable shared cache on SQLITE, reduces SQLITE locking errors.
Per documentation by Sqlite and MS, using `Cache=Shared` is discouraged, especially in combination with WAL. WAL mode is supposed to be the better solution overall, and enabling shared cache changes table locking behaviour increasing errors seen from concurrent actions.
2026-06-03 22:56:37 -04:00

25 lines
865 B
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using RdtClient.Data.Data;
using RdtClient.Data.Models.Internal;
namespace RdtClient.Data;
public static class DiConfig
{
public static void Config(IServiceCollection services, AppSettings appSettings)
{
if (String.IsNullOrWhiteSpace(appSettings.Database?.Path))
{
throw new("Invalid database path found in appSettings");
}
var connectionString = $"Data Source={appSettings.Database.Path};Cache=Private;Pooling=True;Command Timeout=30";
services.AddDbContext<DataContext>(options => options.UseSqlite(connectionString));
services.AddScoped<DownloadData>();
services.AddScoped<SettingData>();
services.AddScoped<ITorrentData, TorrentData>();
services.AddScoped<UserData>();
}
}