Bump the service worker's index.html revision after injecting

Funkwhale's service worker precaches index.html by a build-time revision,
so returning visitors kept the unmodified page. inject.sh now writes the
modified page's hash into serviceWorker.js, which makes browsers install
the updated worker and fetch the new page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-10 15:48:32 -05:00
co-authored by Claude Opus 5.5
parent b8978221a3
commit e89de68bca
3 changed files with 11 additions and 2 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ Install the package and PyJWT into `FUNKWHALE_PLUGINS_PATH` (default `/srv/funkw
```sh
pip install --target /srv/funkwhale/plugins \
https://gitea.eom.dev/DevOps/funkwhale-oidc/archive/v0.2.0.tar.gz
https://gitea.eom.dev/DevOps/funkwhale-oidc/archive/v0.2.1.tar.gz
```
In containers, run this as an init step into a shared volume. `tests/compose.yaml` shows how.
+1 -1
View File
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""OpenID Connect login for Funkwhale, as a Funkwhale plugin."""
__version__ = "0.2.0"
__version__ = "0.2.1"
+9
View File
@@ -23,3 +23,12 @@ if ! grep -q 'location /accounts/' "$conf"; then
grep -q 'location /accounts/' "$conf" || { echo "funkwhale-oidc: could not add /accounts/ to $conf" >&2; exit 1; }
echo "funkwhale-oidc: /accounts/ proxied to the API"
fi
# The web app's service worker precaches index.html by the revision in its
# manifest; without a new revision, returning visitors keep the old page.
sw=/usr/share/nginx/html/serviceWorker.js
if [ -f "$sw" ]; then
rev=$(md5sum "$index" | cut -c1-32)
sed -i "s|\"revision\":\"[0-9a-f]*\",\"url\":\"index.html\"|\"revision\":\"$rev\",\"url\":\"index.html\"|" "$sw"
grep -q "\"revision\":\"$rev\",\"url\":\"index.html\"" "$sw" && echo "funkwhale-oidc: service worker revision for index.html set to $rev"
fi