# Summary: Path Configuration Enhancement

## Changes Made

### ✅ All Paths Are Now Configurable!

All major Jellyfin paths can be configured via command-line options or environment variables:

| Path Type | Command Line | Environment Variable | Default |
|-----------|-------------|---------------------|---------|
| **Program Data** | `-d, --datadir` | `JELLYFIN_DATA_DIR` | `%LocalAppData%/jellyfin` |
| **Configuration** | `-c, --configdir` | `JELLYFIN_CONFIG_DIR` | `{datadir}/config` or XDG |
| **Cache** | `-C, --cachedir` | `JELLYFIN_CACHE_DIR` | `{datadir}/cache` or XDG |
| **Logs** | `-l, --logdir` | `JELLYFIN_LOG_DIR` | `{datadir}/log` |
| **Temp** ⭐ | `-t, --tempdir` | `JELLYFIN_TEMP_DIR` | `{system_temp}/jellyfin` |
| **Web Client** | `-w, --webdir` | `JELLYFIN_WEB_DIR` | `wwwroot` or `jellyfin-web` |

### New Feature: Configurable Temp Directory

**Previously**: Temp directory was hardcoded to `{system_temp}/jellyfin`

**Now**: Fully configurable with:
- Command-line option: `-t, --tempdir <path>`
- Environment variable: `JELLYFIN_TEMP_DIR`
- Maintains backward compatibility with sensible default

## Files Modified

1. **Jellyfin.Server/StartupOptions.cs**
   - Added `TempDir` property with command-line option `-t, --tempdir`

2. **Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs**
   - Changed `TempDirectory` from computed property to stored property
   - Added `tempDirectoryPath` parameter to constructor

3. **Emby.Server.Implementations/ServerApplicationPaths.cs**
   - Added `tempDirectoryPath` parameter to constructor
   - Passes temp directory to base class

4. **Jellyfin.Server/Helpers/StartupHelpers.cs**
   - Added logic to resolve temp directory from options/env var/default
   - Creates temp directory during initialization
   - Passes temp directory to ServerApplicationPaths constructor

## Usage Examples

### Command Line
```bash
# Linux
jellyfin --tempdir /var/tmp/jellyfin

# Windows
jellyfin.exe --tempdir "D:\Temp\Jellyfin"

# All paths at once
jellyfin --datadir /var/lib/jellyfin --configdir /etc/jellyfin --cachedir /var/cache/jellyfin --logdir /var/log/jellyfin --tempdir /var/tmp/jellyfin
```

### Environment Variables
```bash
# Linux/macOS
export JELLYFIN_TEMP_DIR=/var/tmp/jellyfin

# Windows PowerShell
$env:JELLYFIN_TEMP_DIR="D:\Temp\Jellyfin"
```

### Docker Compose
```yaml
version: '3.8'
services:
  jellyfin:
    image: jellyfin/jellyfin:latest
    environment:
      - JELLYFIN_TEMP_DIR=/temp
    volumes:
      - /fast-storage/jellyfin/temp:/temp
```

## Benefits

### Performance
- Place temp directory on fast SSD/NVMe for better transcoding performance
- Separate I/O load across different disks

### Storage Management
- Use different mount points for different types of data
- Easier disk space quota management
- Prevent temp files from filling up data partition

### Security
- Follow OS best practices (Linux FHS, Windows Program Data, etc.)
- Set appropriate permissions per directory type
- Separate user data from temporary files

### Backup & Maintenance
- Exclude temp directory from backups
- Easier cleanup of temporary files
- Better separation of concerns

### Containerization
- Proper volume mapping for ephemeral vs persistent data
- Follow container best practices
- Simplified Docker/Kubernetes configurations

## Testing

✅ Build successful
✅ All paths resolve correctly
✅ Backward compatibility maintained (defaults to `{system_temp}/jellyfin` if not specified)
✅ Directories created automatically during startup
✅ Proper logging of all paths at startup

## Documentation

Created comprehensive documentation in `PATH_CONFIGURATION_GUIDE.md` covering:
- All configurable paths
- Usage examples (CLI, environment variables, systemd, Docker)
- Priority order (CLI > env var > default)
- Permission setup
- Verification steps

## Backward Compatibility

✅ **Fully backward compatible**
- All existing installations will continue to work without changes
- Default behavior unchanged
- New parameters are optional
- No breaking changes to existing configurations

## Related Features

This complements existing path configurations:
- Program data path (already configurable)
- Config directory (already configurable)  
- Cache directory (already configurable)
- Log directory (already configurable)
- Web directory (already configurable)

Now **all major paths** are user-configurable! 🎉
