# Check and Fix system.xml MetadataPath on Windows

## Problem
Even though database stores `%MetadataPath%\People`, the logs show Linux paths.
This means `system.xml` has a Linux path configured for `MetadataPath`.

## Where to Check

### **1. Check your system.xml file**

**Location:** `C:\ProgramData\jellyfin\config\system.xml` (or your config directory)

Look for this line:
```xml
<MetadataPath>/var/lib/jellyfin/metadata</MetadataPath>
```

### **2. What it should be**

**Option A: Empty (Use default)**
```xml
<MetadataPath></MetadataPath>
```
or
```xml
<MetadataPath/>
```

**Option B: Windows path**
```xml
<MetadataPath>C:\ProgramData\jellyfin\data\metadata</MetadataPath>
```

## How to Fix

### **Method 1: Via Jellyfin Dashboard** (Recommended)
1. Open Jellyfin Dashboard
2. Go to **Advanced** → **Paths**
3. Look for **Metadata path**
4. Clear it (to use default) or set it to a Windows path
5. Save
6. Restart Jellyfin

### **Method 2: Edit system.xml Manually**
1. **Stop Jellyfin service/application**
2. Open `C:\ProgramData\jellyfin\config\system.xml` in a text editor
3. Find the `<MetadataPath>` line
4. Change from:
   ```xml
   <MetadataPath>/var/lib/jellyfin/metadata</MetadataPath>
   ```
   To:
   ```xml
   <MetadataPath></MetadataPath>
   ```
   or
   ```xml
   <MetadataPath>C:\ProgramData\jellyfin\data\metadata</MetadataPath>
   ```
5. Save the file
6. Start Jellyfin

### **Method 3: PowerShell Script** (Automated)

```powershell
# Path to your Jellyfin config directory
$configPath = "C:\ProgramData\jellyfin\config\system.xml"

# Backup first
Copy-Item $configPath "$configPath.backup.$(Get-Date -Format 'yyyyMMdd_HHmmss')"

# Read the XML
[xml]$xml = Get-Content $configPath

# Check current MetadataPath
Write-Host "Current MetadataPath: $($xml.ServerConfiguration.MetadataPath)"

# Update to empty (use default) or set a Windows path
$xml.ServerConfiguration.MetadataPath = ""
# Or set to specific path:
# $xml.ServerConfiguration.MetadataPath = "C:\ProgramData\jellyfin\data\metadata"

# Save
$xml.Save($configPath)

Write-Host "Updated MetadataPath to: $($xml.ServerConfiguration.MetadataPath)"
Write-Host "Please restart Jellyfin for changes to take effect"
```

Or use the automated script:
```powershell
.\FixJellyfinPaths.ps1 -DryRun   # Preview changes
.\FixJellyfinPaths.ps1            # Apply fixes
```

## Verification

After fixing, check the logs to see if the Linux paths are gone.

The error should change from:
```
[WRN] Image not found at "/var/lib/jellyfin/metadata/People/D/David L.M. McIntyre/folder.jpg"
```

To:
```
[WRN] Image not found at "C:\ProgramData\jellyfin\data\metadata\People\D\David L.M. McIntyre\folder.jpg"
```

## Why This Happens

1. Database stores: `%MetadataPath%\People\D\David L.M. McIntyre\folder.jpg`
2. Jellyfin expands `%MetadataPath%` using the value from `system.xml`
3. If `system.xml` has `/var/lib/jellyfin/metadata`, the expanded path becomes:
   `/var/lib/jellyfin/metadata\People\D\David L.M. McIntyre\folder.jpg`
4. This creates a mixed Linux/Windows path that doesn't exist

## Other Files to Check

If the issue persists, also check:
1. **`encoding.xml`** - For `TranscodingTempPath`
2. **`network.xml`** - For any path configurations
3. **`database.xml`** - Though this is less likely to have path issues

## Root Cause

When you migrated from Linux to Windows, the `system.xml` configuration file was copied over with Linux paths intact. The database correctly stores virtual paths (`%MetadataPath%`), but the virtual path is expanded using the incorrect Linux path from the config file.
