mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-25 23:18:44 -07:00
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:
@@ -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"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user