Server reads Database:SqlitePath (port from march 46e2bb1)

SQLite path now honors Database:SqlitePath config (Database__SqlitePath
env var). Falls back to the legacy <bin>/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.
This commit is contained in:
Alexa
2026-05-28 14:20:46 +03:00
parent c5db16eeb0
commit 23d328180d
@@ -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 <bin>\data\.
// Existing Docker / standalone deploys that mounted <bin>\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"));
}