Fix HTTPException handling in folder endpoints and install script path
- Add missing `except HTTPException: raise` in create_folder and update_folder endpoints to prevent 400 errors being masked as 500s - Fix install_task_windows.ps1 working directory to point to media-server root instead of parent project root Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -113,6 +113,8 @@ async def create_folder(
|
||||
"message": f"Media folder '{request.folder_id}' created successfully",
|
||||
}
|
||||
|
||||
except HTTPException:
|
||||
raise
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
except Exception as e:
|
||||
@@ -161,6 +163,8 @@ async def update_folder(
|
||||
"message": f"Media folder '{folder_id}' updated successfully",
|
||||
}
|
||||
|
||||
except HTTPException:
|
||||
raise
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
except Exception as e:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Unregister-ScheduledTask -TaskName "MediaServer" -Confirm:$false -ErrorAction SilentlyContinue
|
||||
|
||||
# Get the project root directory (two levels up from this script)
|
||||
$projectRoot = (Get-Item $PSScriptRoot).Parent.Parent.FullName
|
||||
# Get the media-server directory (parent of scripts folder)
|
||||
$serverRoot = (Get-Item $PSScriptRoot).Parent.FullName
|
||||
|
||||
# Find Python executable
|
||||
$pythonPath = (Get-Command python -ErrorAction SilentlyContinue).Source
|
||||
@@ -10,10 +10,10 @@ if (-not $pythonPath) {
|
||||
exit 1
|
||||
}
|
||||
|
||||
$action = New-ScheduledTaskAction -Execute $pythonPath -Argument "-m media_server.main" -WorkingDirectory $projectRoot
|
||||
$action = New-ScheduledTaskAction -Execute $pythonPath -Argument "-m media_server.main" -WorkingDirectory $serverRoot
|
||||
$trigger = New-ScheduledTaskTrigger -AtStartup
|
||||
$principal = New-ScheduledTaskPrincipal -UserId "$env:USERNAME" -LogonType S4U -RunLevel Highest
|
||||
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable
|
||||
Register-ScheduledTask -TaskName "MediaServer" -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Description "Media Server for Home Assistant"
|
||||
|
||||
Write-Host "Scheduled task 'MediaServer' created with working directory: $projectRoot"
|
||||
Write-Host "Scheduled task 'MediaServer' created with working directory: $serverRoot"
|
||||
|
||||
Reference in New Issue
Block a user