Fix "Argument list too long" in sonarr.sh for large imports
api_post/api_put passed the JSON payload directly as a curl -d command-line argument, which hit the OS ARG_MAX limit importing Jeopardy's 1269-file library (a large date-based show is exactly the case where a batch import payload gets big). Now written to a temp file and passed via curl's -d @file instead. Claude-Session: https://claude.ai/code/session_01HZQK6jHmdTpFjFZM8FUnqA
This commit is contained in:
@@ -45,14 +45,26 @@ api_get_query() {
|
|||||||
curl -s -G -H "$AUTH_HEADER" "$API/$path" "$@"
|
curl -s -G -H "$AUTH_HEADER" "$API/$path" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Payload goes through a temp file (curl -d @file), not as a command-line
|
||||||
|
# argument - a large library (e.g. Jeopardy's 1269-file import payload) can
|
||||||
|
# exceed the OS argument-length limit and fail with "Argument list too long"
|
||||||
|
# if passed directly via -d "$2".
|
||||||
api_post() {
|
api_post() {
|
||||||
|
local payload_file
|
||||||
|
payload_file=$(mktemp)
|
||||||
|
printf '%s' "$2" > "$payload_file"
|
||||||
curl -s -X POST -H "$AUTH_HEADER" -H "Content-Type: application/json" \
|
curl -s -X POST -H "$AUTH_HEADER" -H "Content-Type: application/json" \
|
||||||
-d "$2" "$API/$1"
|
-d "@$payload_file" "$API/$1"
|
||||||
|
rm -f "$payload_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
api_put() {
|
api_put() {
|
||||||
|
local payload_file
|
||||||
|
payload_file=$(mktemp)
|
||||||
|
printf '%s' "$2" > "$payload_file"
|
||||||
curl -s -X PUT -H "$AUTH_HEADER" -H "Content-Type: application/json" \
|
curl -s -X PUT -H "$AUTH_HEADER" -H "Content-Type: application/json" \
|
||||||
-d "$2" "$API/$1"
|
-d "@$payload_file" "$API/$1"
|
||||||
|
rm -f "$payload_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user