From 53cf705799c4bf6a959c0a75ab3b2e85542274cd Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Tue, 10 Feb 2026 08:17:50 +0100 Subject: [PATCH] Format misc/api.func: spacing and heredocs Clean up formatting in misc/api.func for readability. Normalized spacing in the categorize_error case patterns, removed trailing blank-space lines, and standardized detect_gpu blank-line spacing. Converted heredoc assignments to use multiline $() style for JSON_PAYLOAD in post_tool_to_api, post_addon_to_api, and post_update_to_api_extended, and added a final newline at end of file. No functional changes intended; purely whitespace/formatting cleanup. --- misc/api.func | 81 ++++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/misc/api.func b/misc/api.func index a1f6802dd..a2a178245 100644 --- a/misc/api.func +++ b/misc/api.func @@ -422,29 +422,29 @@ EOF categorize_error() { local code="$1" case "$code" in - # Network errors - 6|7|22|28|35) echo "network" ;; - - # Storage errors - 214|217|219) echo "storage" ;; - - # Dependency/Package errors - 100|101|102|127|160|161|162) echo "dependency" ;; - - # Permission errors - 126|152) echo "permission" ;; - - # Timeout errors - 124|28|211) echo "timeout" ;; - - # Configuration errors - 203|204|205|206|207|208) echo "config" ;; - - # Resource errors (OOM, etc) - 137|134) echo "resource" ;; - - # Default - *) echo "unknown" ;; + # Network errors + 6 | 7 | 22 | 28 | 35) echo "network" ;; + + # Storage errors + 214 | 217 | 219) echo "storage" ;; + + # Dependency/Package errors + 100 | 101 | 102 | 127 | 160 | 161 | 162) echo "dependency" ;; + + # Permission errors + 126 | 152) echo "permission" ;; + + # Timeout errors + 124 | 28 | 211) echo "timeout" ;; + + # Configuration errors + 203 | 204 | 205 | 206 | 207 | 208) echo "config" ;; + + # Resource errors (OOM, etc) + 137 | 134) echo "resource" ;; + + # Default + *) echo "unknown" ;; esac } @@ -485,13 +485,13 @@ get_install_duration() { detect_gpu() { GPU_VENDOR="" GPU_PASSTHROUGH="none" - + # Detect Intel GPU if lspci 2>/dev/null | grep -qi "VGA.*Intel"; then GPU_VENDOR="intel" GPU_PASSTHROUGH="igpu" fi - + # Detect AMD GPU if lspci 2>/dev/null | grep -qi "VGA.*AMD\|VGA.*ATI"; then GPU_VENDOR="amd" @@ -502,13 +502,13 @@ detect_gpu() { GPU_PASSTHROUGH="igpu" fi fi - + # Detect NVIDIA GPU if lspci 2>/dev/null | grep -qi "VGA.*NVIDIA\|3D.*NVIDIA"; then GPU_VENDOR="nvidia" GPU_PASSTHROUGH="dgpu" fi - + export GPU_VENDOR GPU_PASSTHROUGH } @@ -535,10 +535,10 @@ post_tool_to_api() { # Generate UUID for this tool execution uuid=$(cat /proc/sys/kernel/random/uuid 2>/dev/null || uuidgen 2>/dev/null || echo "tool-$(date +%s)") duration=$(get_install_duration) - + # Map status [[ "$status" == "done" ]] && status="success" - + if [[ "$status" == "failed" ]]; then [[ ! "$exit_code" =~ ^[0-9]+$ ]] && exit_code=1 error=$(explain_exit_code "$exit_code") @@ -551,7 +551,8 @@ post_tool_to_api() { fi local JSON_PAYLOAD - JSON_PAYLOAD=$(cat </dev/null || uuidgen 2>/dev/null || echo "addon-$(date +%s)") duration=$(get_install_duration) - + # Map status [[ "$status" == "done" ]] && status="success" - + if [[ "$status" == "failed" ]]; then [[ ! "$exit_code" =~ ^[0-9]+$ ]] && exit_code=1 error=$(explain_exit_code "$exit_code") @@ -615,7 +616,8 @@ post_addon_to_api() { fi local JSON_PAYLOAD - JSON_PAYLOAD=$(cat </dev/null || true POST_UPDATE_DONE=true -} \ No newline at end of file +}