Postgres perf, path migration, and shutdown race fixes

- Major query performance boost: replaced correlated subqueries with DistinctBy() in BaseItemRepository, added episode deduplication index, and increased default command timeout to 120s.
- Fixed LibraryMonitor shutdown race: added disposal checks and exception handling in FileRefresher to prevent ObjectDisposedException.
- Added PowerShell and SQL utilities for fixing Linux paths in config files and database; new scripts for WebDir and path migration.
- Auto-fix for WebDir in startup.json on load; new helper scripts and docs.
- Added automated weekly DB performance monitoring scripts and reporting.
- Expanded documentation and README for all fixes, scripts, and migration steps.
- Updated SQL scripts for index creation and diagnostics; improved output handling.
- Updated db-config defaults and added new diagnostic/report files.
This commit is contained in:
2026-03-05 08:56:42 -05:00
parent 0eb44818ff
commit 7eb2b445cb
44 changed files with 3504 additions and 23 deletions
+42
View File
@@ -70,6 +70,45 @@ public static class StartupHelpers
logger.LogInformation("Application directory: {ApplicationPath}", appPaths.ProgramSystemPath);
}
/// <summary>
/// Fixes incorrect absolute WebDir paths in startup.json to use relative paths.
/// This handles legacy configurations that used absolute paths like "C:/ProgramData/jellyfin/wwwroot".
/// </summary>
/// <param name="configPath">Path to the startup.json file.</param>
private static void FixWebDirPath(string configPath)
{
try
{
var content = File.ReadAllText(configPath);
var originalContent = content;
// Fix Windows absolute paths
content = System.Text.RegularExpressions.Regex.Replace(
content,
@"""WebDir"":\s*""[^""]*[/\\]jellyfin[/\\](?:data[/\\])?wwwroot""",
@"""WebDir"": ""wwwroot""",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// Fix Linux absolute paths
content = System.Text.RegularExpressions.Regex.Replace(
content,
@"""WebDir"":\s*""[^""]*[/\\]usr[/\\]share[/\\]jellyfin[/\\]wwwroot""",
@"""WebDir"": ""wwwroot""",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// Only write if changed
if (content != originalContent)
{
File.WriteAllText(configPath, content);
Console.WriteLine($"Fixed WebDir path in: {configPath}");
}
}
catch (Exception ex)
{
Console.WriteLine($"Warning: Could not fix WebDir path in {configPath}: {ex.Message}");
}
}
/// <summary>
/// Loads startup configuration from startup.json file if it exists.
/// If no configuration file exists, creates a default one in the application directory.
@@ -93,6 +132,9 @@ public static class StartupHelpers
{
try
{
// Check and fix incorrect WebDir paths before loading
FixWebDirPath(configPath);
var config = new ConfigurationBuilder()
.AddJsonFile(configPath, optional: false, reloadOnChange: false)
.Build();