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")); }