perf(backup): drop sudo overhead from sourceBackupLocations (Phase 6)
The location_loader's find ran through runFileOp (sudo -u libreportal), which forks a sudo shell purely for the find call. configs/backup/ locations/ is already manager-owned (not in the dockerinstall-owned containers tree), so the sudo step adds ~50 ms of process-creation overhead for zero security benefit. Plain `find` now, with a tiny [[ ! -r || ! -x ]] guard that falls back to runFileOp if someone relocates the dir to a non-traversable location. Same observable behaviour, ~50 ms saved per CLI invocation. This is the simpler half of Phase 6 — the libreportal_configs scan itself was already plain-find (only ~11 ms total for 22 files). The remaining costly scan is app_configs against /libreportal-containers/, which legitimately needs sudo because dockerinstall owns that tree. Precompiling its content is possible but adds invalidation complexity (updateConfigOption writes happen at runtime) — deferred for now; better return on simpler interventions. Signed-off-by: librelad <librelad@digitalangels.vip>
This commit is contained in:
parent
52c74d4c09
commit
c6d92bbc58
@ -11,8 +11,18 @@ sourceBackupLocations()
|
|||||||
dir=$(backupLocationsDir)
|
dir=$(backupLocationsDir)
|
||||||
[[ ! -d "$dir" ]] && return 0
|
[[ ! -d "$dir" ]] && return 0
|
||||||
|
|
||||||
|
# configs/backup/locations/ lives in the manager-owned configs tree (not
|
||||||
|
# the dockerinstall-owned containers tree), so a plain find works fine.
|
||||||
|
# runFileOp was adding ~50 ms of sudo-shell overhead per invocation for
|
||||||
|
# no benefit. Fall back to runFileOp only if the directory isn't readable
|
||||||
|
# for some reason (relocated tree, custom permissions, …).
|
||||||
|
local find_cmd=(find)
|
||||||
|
if [[ ! -r "$dir" || ! -x "$dir" ]] && declare -f runFileOp >/dev/null 2>&1; then
|
||||||
|
find_cmd=(runFileOp find)
|
||||||
|
fi
|
||||||
|
|
||||||
local cfg
|
local cfg
|
||||||
while IFS= read -r -d '' cfg; do
|
while IFS= read -r -d '' cfg; do
|
||||||
[[ -f "$cfg" ]] && source "$cfg"
|
[[ -f "$cfg" ]] && source "$cfg"
|
||||||
done < <(runFileOp find "$dir" -mindepth 2 -maxdepth 2 -name location.config -type f -print0 2>/dev/null)
|
done < <("${find_cmd[@]}" "$dir" -mindepth 2 -maxdepth 2 -name location.config -type f -print0 2>/dev/null)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user