Add file-based startup config & temp dir option
Added support for configuring all major Jellyfin paths (data, config, cache, log, temp, web) via a `startup.json` file, with priority after CLI and environment variables. Introduced a new `TempDir` option, configurable through CLI, env var, or config file, with backward-compatible defaults. Refactored path resolution logic to integrate file-based config and ensure directory creation. Updated constructors and CLI options to support temp directory. Improved EF Core migration error handling and logging. Added comprehensive documentation and example config files. All changes are backward compatible.
This commit is contained in:
+18
-6
@@ -157,7 +157,9 @@ public sealed class PostgresDatabaseProvider : IJellyfinDatabaseProvider
|
||||
options
|
||||
.UseNpgsql(
|
||||
connectionString,
|
||||
npgsqlOptions => npgsqlOptions.MigrationsAssembly(GetType().Assembly.FullName));
|
||||
npgsqlOptions => npgsqlOptions.MigrationsAssembly(GetType().Assembly.FullName))
|
||||
.ConfigureWarnings(warnings =>
|
||||
warnings.Ignore(Microsoft.EntityFrameworkCore.Diagnostics.RelationalEventId.PendingModelChangesWarning));
|
||||
|
||||
var enableSensitiveDataLogging = GetOption(customOptions, "EnableSensitiveDataLogging", e => e.Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase), () => false);
|
||||
if (enableSensitiveDataLogging)
|
||||
@@ -341,12 +343,22 @@ public sealed class PostgresDatabaseProvider : IJellyfinDatabaseProvider
|
||||
|
||||
if (pendingMigrationsList.Count > 0)
|
||||
{
|
||||
logger.LogInformation("Found {Count} pending migrations. Applying migrations...", pendingMigrationsList.Count);
|
||||
logger.LogInformation("Found {Count} pending migrations: {Migrations}", pendingMigrationsList.Count, string.Join(", ", pendingMigrationsList));
|
||||
logger.LogInformation("Applying migrations...");
|
||||
|
||||
// Apply all pending migrations
|
||||
await context.Database.MigrateAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
logger.LogInformation("Successfully applied {Count} migrations", pendingMigrationsList.Count);
|
||||
try
|
||||
{
|
||||
// Apply all pending migrations
|
||||
await context.Database.MigrateAsync(cancellationToken).ConfigureAwait(false);
|
||||
logger.LogInformation("Successfully applied {Count} migrations", pendingMigrationsList.Count);
|
||||
}
|
||||
catch (InvalidOperationException ex) when (ex.Message.Contains("pending changes", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// This can happen if the model has changed but migrations haven't been generated
|
||||
logger.LogWarning("Model has pending changes. This may indicate missing migration files. Error: {Message}", ex.Message);
|
||||
logger.LogWarning("If you're seeing this on a test/production system, ensure all migration files are deployed.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user