HifiPlanet-Website/hifi/assets
Maaxxs 3ea5bd4201 Add one-click git-based auto-update (manual trigger only)
Phase 6 of the dashboard roadmap - the largest and riskiest item, since
it overwrites live production code. Pulls the current main branch from
the public Gitea repo over plain HTTPS (archive zip download + REST API
for commit info) and applies it to the live hifi/ tree - no SSH,
git binary, exec(), or shell_exec() anywhere, so it works on plain
shared PHP hosting with no CI/deploy pipeline (exactly the hosting this
site actually runs on, per DEPLOY.md's manual-FTP fallback).

Six independent endpoints (status/check/download/extract/backup/apply)
instead of one big request, mirroring the existing multi-step
SetupController pattern - this app has no job-queue infrastructure, and
a single ~127MB download+extract+backup+copy is the most likely way to
hit an unknown host's max_execution_time or reverse-proxy timeout.
GitUpdateService.php does the actual work; UpdateController.php is a
thin adapter that marks each step in-progress/failed in a new gitignored
update-state.php (same convention as db.php) so a crashed step shows as
failed rather than stuck, and a retry starts clean.

Security-critical bits:
- The backup zip necessarily contains db.php (must be fully restorable),
  so it lives under hifi/_update/ behind a "Require all denied" .htaccess
  written the instant the directory is created, and hifi/_update/ was
  added to .gitignore in this same commit, before any code that could
  write into it - both needed since a physically-existing file bypasses
  this app's SPA-fallback/API rewrite rules entirely.
- Only hifi/'s own subtree is extracted from the archive (hifi-src/ and
  everything else ignored) via a wrapper-folder-prefix detected at
  runtime, not hardcoded.
- Copy-then-prune (not copy-only) across the whole hifi/ tree, since
  Vite renames JS/CSS chunks on every build and a copy-only updater
  would let stale chunks accumulate forever - guarded by a denylist
  (db.php, setup.php, ga-service-account.json, update-state.php,
  api/uploads/, plus local Claude-tooling dirs) that must never be
  touched in either direction.
- index.html is swapped in last via copy+rename (near-atomic), after
  the new hashed assets it references are already fully in place.
- Reuses SchemaController's existing migration logic as the last apply
  step (extracted into a new runMigration() so it's callable without
  Http::send()/exit ending the response early) and app_settings'
  existing maintenance-mode column to show visitors a maintenance page
  during the brief apply window, restoring whatever maintenance state
  existed before the update ran (not just forcing it off).

Gated behind a new, narrower system.update permission (not the broader
settings.manage), with its own settings tab hidden from anyone lacking
it - unlike this app's usual "everyone with settings.manage sees every
tab" pattern, since this one can overwrite the whole site.

Verified in isolation (synthetic zip + fixture directories in a scratch
folder, not the real hifi/ tree): wrapper-folder detection and
selective hifi/-subtree extraction, and copy+prune with denylist
enforcement. Not yet verified: behavior on an actual shared-hosting
target (max_execution_time, ZipArchive availability, outbound HTTPS
egress, disk quota vs disk_free_space()) - per the plan, validate
against the Plesk test server from DEPLOY.md before ever running this
against a real client site. Also enabled the php_zip extension in the
local XAMPP php.ini, since it was disabled and this feature needs it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-09 02:16:41 +02:00
..
apex-CFy2qup8.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
base-BKOm0Bib.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
bg-dark-DX_vTCv2.png Use the handoff's baked background images for the contact section 2026-07-20 07:24:59 +02:00
bg-light-C_7mxjWZ.png Use the handoff's baked background images for the contact section 2026-07-20 07:24:59 +02:00
clear-DZZMSrMX.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
drive-BE2W1yna.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
elite_r-BRvz_pyr.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
gallery-amp-purple-CESAKuOf.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
gallery-dash-Cg-7v9qo.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
gallery-dash2-CEVCErVK.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
gallery-rear-8cIXPC7T.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
gallery-speaker-CUXQZ49Q.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
gallery-subs-COSd4seJ.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
hero-highlight-Co4f1Kj5.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
hero-trunk-Dp4_JHDh.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
index-DHi-eHhm.css Add CMS v1: editable business identity and legal pages 2026-09-09 02:03:59 +02:00
index-DMjv3wnD.js Add one-click git-based auto-update (manual trigger only) 2026-09-09 02:16:41 +02:00
limitless-DDs0S_PU.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
logo-BNfZDkmN.png Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
logo-dark-R-ckaBhx.png Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
lucide-icons-Cg2IxtAO.js Add rich-text formatting and font choice for email templates 2026-09-09 01:49:13 +02:00
prime-BTVNe2Gb.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
statement-pTO-wTPx.webp Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00
youtube-hintergrund-C0osNxn7.mp4 Consolidate the site onto a single branch: main now carries the build output 2026-07-20 06:59:33 +02:00