From 23d328180d87d2064a7cfab37f8cf7643e157f32 Mon Sep 17 00:00:00 2001 From: Alexa <53471801+Alexa-RR@users.noreply.github.com> Date: Thu, 28 May 2026 14:20:46 +0300 Subject: [PATCH] Server reads Database:SqlitePath (port from march 46e2bb1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SQLite path now honors Database:SqlitePath config (Database__SqlitePath env var). Falls back to the legacy /data/dorknet.db default so existing Docker / standalone deploys are unchanged. Lets the Windows launcher put the db under %APPDATA%\DorkNet — server cache reinstalls no longer wipe player accounts / rooms. --- DorkNet.Server/Startup/ServiceCollectionExtensions.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/DorkNet.Server/Startup/ServiceCollectionExtensions.cs b/DorkNet.Server/Startup/ServiceCollectionExtensions.cs index ee1f628..74e013d 100644 --- a/DorkNet.Server/Startup/ServiceCollectionExtensions.cs +++ b/DorkNet.Server/Startup/ServiceCollectionExtensions.cs @@ -78,7 +78,15 @@ public static class ServiceCollectionExtensions } else { - var dbPath = Path.Combine(AppContext.BaseDirectory, "data", "dorknet.db"); + // Honor an explicit path the host can set via env var + // (Database__SqlitePath) or appsettings (Database:SqlitePath). + // The Windows launcher sets this to %APPDATA%\DorkNet\dorknet.db + // so server installs don't accumulate state under \data\. + // Existing Docker / standalone deploys that mounted \data\ + // keep working because that's still the fallback. + var dbPath = builder.Configuration["Database:SqlitePath"]; + if (string.IsNullOrWhiteSpace(dbPath)) + dbPath = Path.Combine(AppContext.BaseDirectory, "data", "dorknet.db"); Directory.CreateDirectory(Path.GetDirectoryName(dbPath)!); opt.UseSqlite($"Data Source={dbPath}", lite => lite.MigrationsAssembly("DorkNet.Server")); }