LibrePortal/scripts/cli/commands/system/cli_system_commands.sh
librelad 49cf7e8bec ux(system): move Reclaim button top-right, make it actually free space
Three fixes from testing the storage page:

- Placement: the "Reclaim space" button moves into the page header,
  top-right (matching the metric page), instead of sitting in the body.

- It now actually reclaims: build cache needs -a to drop (docker reports
  0 B "reclaimable" without it, but it's pure cache — safe to clear), so
  the CLI uses `docker builder prune -af`. Previously the safe scope
  freed ~nothing on a box whose reclaimable was mostly cache.

- Honest "Reclaimable" number: /api/system/storage was counting the
  whole build cache AND unused tagged images, overstating what the safe
  prune frees (e.g. 340 MB shown, ~96 MB per docker, button cleared 0).
  Reclaimable now = dangling images + build cache only; stopped
  containers and volumes are never counted (the safe prune never touches
  them). Headline now matches the button's effect.

Also simplify the CLI output (drop the jargony scope notice and the
reclaimed-total greps) and re-enable the now-persistent header button
after the post-reclaim refreshes.

Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-28 19:06:02 +01:00

49 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# System Commands Handler
# Handles all system subcommands by calling core functions
# Safe disk reclaim: clear the whole build cache (-a; it's pure cache, always
# safe to drop) and remove dangling images. Never touches volumes or in-use
# images. runFileOp hits the right daemon (rootless: as the install user).
reclaimDockerSpace()
{
isHeader "Reclaiming Space"
runFileOp docker builder prune -af >/dev/null 2>&1
checkSuccess "Cleared build cache"
runFileOp docker image prune -f >/dev/null 2>&1
checkSuccess "Removed dangling images"
isSuccessful "Done"
}
cliHandleSystemCommands()
{
local action="$initial_command2"
case "$action" in
"status")
tagsValidateShowSystemStatus
;;
"update")
checkUpdates
;;
"reset")
runReinstall
;;
"reclaim")
reclaimDockerSpace
;;
*)
isNotice "Invalid system command: $action"
cliShowSystemHelp
;;
esac
}