From ad85bc0326d9f5f28996dfd3521d45b1e578e030 Mon Sep 17 00:00:00 2001 From: boban Date: Sun, 26 Apr 2026 20:20:21 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20=5Fcleanup=20=C3=BCberschreibt=20keinen?= =?UTF-8?q?=20frisch=20gebauten=20Cache=20mehr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fix_ownership() getrennt von fix_permissions() (nur chown/chmod, kein optimize) - _cleanup: bei Erfolg nur fix_ownership, bei Fehler fix_permissions (mit optimize) - Verhindert dass _cleanup nach erfolgreichem Update den View-Cache wieder löscht Co-Authored-By: Claude Sonnet 4.6 --- scripts/update.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/update.sh b/scripts/update.sh index 4c34202..f113b72 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -168,7 +168,7 @@ _sudoers_add(){ printf '%s\n' "$rule" >> "$file" chmod 440 "$file" } -fix_permissions(){ +fix_ownership(){ # Alle App-Dateien dem APP_USER zuweisen (git läuft als root → neue Dateien wären sonst root-owned) # node_modules + vendor ausklammern (zu groß, werden separat behandelt) for d in app bootstrap config database public resources routes scripts storage; do @@ -177,10 +177,13 @@ fix_permissions(){ for f in artisan composer.json composer.lock package.json package-lock.json .env vite.config.js vite.config.ts; do [[ -e "${APP_DIR}/${f}" ]] && chown "${APP_USER}:${APP_GROUP}" "${APP_DIR}/${f}" 2>/dev/null || true done - chmod -R ug+rwX "${APP_DIR}/bootstrap/cache" "${APP_DIR}/storage" 2>/dev/null || true find "${APP_DIR}/bootstrap/cache" "${APP_DIR}/storage" \ -type d -exec chmod g+s {} \; 2>/dev/null || true +} + +fix_permissions(){ + fix_ownership # Frontend fehlt → rebuild if [[ ! -f "${APP_DIR}/public/build/manifest.json" ]]; then @@ -272,8 +275,13 @@ MAINTENANCE_ACTIVE=0 _cleanup() { local rc=$? [[ "$MAINTENANCE_ACTIVE" -eq 1 ]] && artisan_up - # Rechte + Cache IMMER korrigieren — auch bei Fehler-Abbruch - fix_permissions + # Ownership immer korrigieren; Cache nur bei Fehler neu aufbauen + # (bei Erfolg hat fix_permissions im Hauptfluss bereits optimize gebaut) + if [[ $rc -ne 0 ]]; then + fix_permissions + else + fix_ownership + fi mkdir -p "$STATE_DIR" echo "done" > "$STATE_DIR/state" echo "$rc" > "$STATE_DIR/rc"