Files
pgsql-jellyfin/docs/STARTUP_JSON_WEBDIR_FIX.md
wjones 7eb2b445cb 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.
2026-03-05 08:56:42 -05:00

124 lines
3.6 KiB
Markdown

# Fix: startup.json Still Has Wrong WebDir
## Problem
After fixing the code, `startup.json` is still created with:
```json
"WebDir": "C:/ProgramData/jellyfin/wwwroot"
```
Instead of:
```json
"WebDir": "wwwroot"
```
## Root Cause
The fix in `StartupHelpers.cs` (line 141) only affects **newly created** files. If `startup.json` already exists in one of these locations, it won't be recreated:
1. Current directory: `D:\Projects\pgsql-jellyfin\startup.json`
2. Application directory: `bin\Debug\net11.0\startup.json`
3. Config directory: `bin\Debug\net11.0\config\startup.json`
## Solutions
### **Solution 1: Delete Existing startup.json** (Quickest)
Delete the existing `startup.json` file and let Jellyfin recreate it with correct values:
```powershell
# Find and delete startup.json files
Remove-Item -Path ".\startup.json" -ErrorAction SilentlyContinue
Remove-Item -Path ".\bin\Debug\net11.0\startup.json" -ErrorAction SilentlyContinue
Remove-Item -Path ".\bin\Debug\net11.0\config\startup.json" -ErrorAction SilentlyContinue
Remove-Item -Path ".\bin\Release\net11.0\startup.json" -ErrorAction SilentlyContinue
Remove-Item -Path ".\bin\Release\net11.0\config\startup.json" -ErrorAction SilentlyContinue
Write-Host "Deleted existing startup.json files. Run Jellyfin to recreate with correct paths."
```
### **Solution 2: Edit Existing startup.json Manually**
1. Find the file: `startup.json`
2. Open in a text editor
3. Change:
```json
"WebDir": "C:/ProgramData/jellyfin/wwwroot"
```
To:
```json
"WebDir": "wwwroot"
```
4. Save
### **Solution 3: PowerShell Script to Fix All Instances**
```powershell
# Fix WebDir in all startup.json files
$files = Get-ChildItem -Path . -Recurse -Filter "startup.json" -ErrorAction SilentlyContinue
foreach ($file in $files) {
Write-Host "Checking: $($file.FullName)"
$content = Get-Content $file.FullName -Raw
# Check if it has the wrong path
if ($content -match '"WebDir":\s*"C:/ProgramData/jellyfin/wwwroot"') {
Write-Host " -> Found incorrect WebDir, fixing..." -ForegroundColor Yellow
# Backup
Copy-Item $file.FullName "$($file.FullName).backup"
# Fix it
$newContent = $content -replace '"WebDir":\s*"C:/ProgramData/jellyfin/wwwroot"', '"WebDir": "wwwroot"'
Set-Content -Path $file.FullName -Value $newContent
Write-Host " -> Fixed! (Backup created)" -ForegroundColor Green
} else {
Write-Host " -> Already correct" -ForegroundColor Green
}
}
Write-Host ""
Write-Host "Done! Rebuild and run Jellyfin." -ForegroundColor Cyan
```
### **Solution 4: Add Code to Auto-Fix on Startup** (Most Robust)
Add code to automatically update incorrect paths when loading the config file. This ensures old config files are fixed automatically.
I can implement this in `StartupHelpers.cs` if you want.
## Verification
After applying a fix, check your `startup.json`:
```powershell
Get-Content startup.json | Select-String "WebDir"
```
Should show:
```json
"WebDir": "wwwroot"
```
Not:
```json
"WebDir": "C:/ProgramData/jellyfin/wwwroot"
```
## Why This Matters
Using relative path `"wwwroot"` instead of absolute path:
- ✅ Makes installation portable
- ✅ Works regardless of where Jellyfin is installed
- ✅ Matches the template file `startup.json.windows`
- ✅ Consistent with other platforms
## Next Steps
1. **Choose a solution above** (I recommend Solution 1 - delete and recreate)
2. **Rebuild** the project
3. **Run** Jellyfin
4. **Verify** the new `startup.json` has `"WebDir": "wwwroot"`
Would you like me to implement Solution 4 (auto-fix code) to prevent this issue in the future?