fix(remote): preserve pairing on failed forget and respect asset cache policy

This commit is contained in:
Xubin Ren committed 2026-10-02 11:36:34 +08:00
1 parent 49eb3a27f9
commit fd9681ef8b
4 files changed
+56 -8

No files matched your search

+9 -5
View File
@@ -400,15 +400,19 @@ class RemoteInstances:
self._unknown_hosts.discard(key)
return {"trusted": True}
if action in {"disconnect", "remove"}:
pair_id = profiles[key].pair_id
if action == "remove":
self._remember_origins(profiles)
del profiles[key]
# Commit the directory before destroying its credentials.
# A failed save must leave the listed connection usable.
self._write(profiles)
connection = self.connections.pop(key, None)
if connection:
await connection.proxy.pause()
if action == "remove":
self._remember_origins(profiles)
if profiles[key].pair_id:
self.pairing.forget(profiles[key].pair_id)
del profiles[key]
self._write(profiles)
if pair_id:
self.pairing.forget(pair_id)
self._known_hosts(key).unlink(missing_ok=True)
self._unknown_hosts.discard(key)
self._unverified.pop(key, None)
+2 -1
View File
@@ -313,10 +313,11 @@ class RemoteProxy:
and not request.rel_url.query and "set-cookie" not in upstream.headers
and "public" in upstream_cache and "immutable" in upstream_cache
and "no-store" not in upstream_cache and "private" not in upstream_cache
and "no-cache" not in upstream_cache and "must-revalidate" not in upstream_cache
and "application/json" not in upstream.headers.get("content-type", "")):
# Only versioned public build assets, never HTML, API data,
# credentials or media capabilities. Keep caches browser-local.
outgoing["Cache-Control"] = "private, max-age=31536000, immutable"
outgoing["Cache-Control"] = re.sub(r"\bpublic\b", "private", upstream_cache)
if "application/json" in upstream.headers.get("content-type", ""):
body = bytearray()
async for chunk in upstream.aiter_bytes():