diff --git a/soapbox/app.py b/soapbox/app.py index 81ebfda..7d3805e 100644 --- a/soapbox/app.py +++ b/soapbox/app.py @@ -41,8 +41,9 @@ def create_app(cfg: Config | None = None) -> Flask: gitstore.ensure_repo(cfg.content_dir) _bootstrap_owner(cfg) - if not cfg.public_dir.exists(): - build_site(cfg) + # Bygg alltid ved oppstart: etter en oppgradering kan maler/tema ha endret + # seg uten at innholdet har det, og da ville public/ vært utdatert. + build_site(cfg) @app.before_request def _open_db(): diff --git a/tests/test_app.py b/tests/test_app.py index 3a09710..6b80d05 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -225,3 +225,11 @@ def test_user_theme_in_content_repo(client, cfg): f"/admin/edit/{pid}", data={"csrf": token, "title": "P", "body": "x", "action": "publish"} ) assert '
' in client.get("/p/").text + + +def test_rebuild_on_startup(cfg): + """Utdatert public/ (f.eks. etter oppgradering) skal erstattes ved oppstart.""" + cfg.public_dir.mkdir(parents=True) + (cfg.public_dir / "index.html").write_text("GAMMEL") + create_app(cfg) + assert "GAMMEL" not in (cfg.public_dir / "index.html").read_text()