From cbd85af2a3843610e0067a0e95111ac7c385c4fd Mon Sep 17 00:00:00 2001 From: sudolulo Date: Mon, 15 Jun 2026 15:53:06 +0000 Subject: [PATCH] Fix six quality findings from iterative code review - patch_ui.py: find_bundle now matches MARKER so already-patched files return early and print 'UI already patched' instead of the misleading 'filterByProviders pattern not found' warning - install.sh: scope warning grep to current run only (record log offset before apply.sh, tail -c +N to read only new bytes) - install.sh: fix misleading 'before continuing' wording on warning banner - install.sh: fix grep anchor (^WARNING: missed [truecloud-patch] WARNING: lines) - uninstall.sh: add import-middlewared verification after Python detection, matching apply.sh fallback logic --- install.sh | 5 +++++ patch/patch_ui.py | 2 +- uninstall.sh | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 7db705e..4b59482 100755 --- a/install.sh +++ b/install.sh @@ -84,11 +84,16 @@ fi # ── Apply now ───────────────────────────────────────────────────────────────── echo "Applying patches ..." +_log_start=$(wc -c < "$PATCH_DIR/apply.log" 2>/dev/null || echo 0) bash "$PATCH_DIR/apply.sh" echo "" echo "Patch log ($PATCH_DIR/apply.log):" tail -30 "$PATCH_DIR/apply.log" echo "" +if tail -c "+$((_log_start + 1))" "$PATCH_DIR/apply.log" 2>/dev/null | grep -q "WARNING:"; then + echo "WARNING: apply.sh reported one or more issues — see log above for details." + echo "" +fi # ── Restart middlewared ─────────────────────────────────────────────────────── diff --git a/patch/patch_ui.py b/patch/patch_ui.py index 57618de..b93f73b 100644 --- a/patch/patch_ui.py +++ b/patch/patch_ui.py @@ -58,7 +58,7 @@ def find_bundle(): try: with open(path, encoding="utf-8", errors="replace") as fh: content = fh.read() - if FIND.search(content): + if FIND.search(content) or MARKER in content: return webui, path, content except OSError: continue diff --git a/uninstall.sh b/uninstall.sh index 9a49b41..b7a0426 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -58,6 +58,14 @@ if [ -x /usr/bin/middlewared ]; then fi fi +if ! "$PYTHON" -c "import middlewared" 2>/dev/null; then + echo " WARNING: '$PYTHON' cannot import middlewared; falling back to python3" + PYTHON="python3" + if ! "$PYTHON" -c "import middlewared" 2>/dev/null; then + echo " WARNING: 'python3' also cannot import middlewared; sitecustomize.py may be removed from the wrong location." + fi +fi + SITE_PKG=$("$PYTHON" -c "import site; print(site.getsitepackages()[0])" 2>/dev/null || true) if [ -n "$SITE_PKG" ] && [ -f "$SITE_PKG/sitecustomize.py" ]; then