[eric] publish: send output_id + override to cloud so republish reuses the slug

This commit is contained in:
ciregenz
2026-06-19 04:15:02 -07:00
parent 722a9e896a
commit 21a0694914
2 changed files with 14 additions and 3 deletions
+8 -1
View File
@@ -775,7 +775,14 @@ async def publish_output(body: PublishRequest):
dist = await build_static(output)
bundle = collect_bundle(output, dist)
slug_hint = slugify(body.slug or output.name)
res = await upload_to_cloud(settings, name=output.name, slug_hint=slug_hint, bundle=bundle)
res = await upload_to_cloud(
settings,
output_id=output.id,
name=output.name,
slug_hint=slug_hint,
bundle=bundle,
override=body.force,
)
except PublishError as e:
output.publish_status = "error"
output.publish_error = str(e)
+6 -2
View File
@@ -280,7 +280,9 @@ def _safe_detail(resp: httpx.Response, fallback: str) -> str:
return fallback
async def upload_to_cloud(settings, *, name: str, slug_hint: str, bundle: bytes) -> dict:
async def upload_to_cloud(
settings, *, output_id: str, name: str, slug_hint: str, bundle: bytes, override: bool
) -> dict:
token, base = _cloud_auth(settings)
if not token:
raise PublishError("Sign in to your OpenSwarm account to publish apps.")
@@ -289,7 +291,9 @@ async def upload_to_cloud(settings, *, name: str, slug_hint: str, bundle: bytes)
r = await client.post(
f"{base}/api/apps/publish",
headers={"Authorization": f"Bearer {token}"},
data={"name": name, "slug": slug_hint},
# output_id lets the cloud reuse this app's slug on republish instead
# of minting a duplicate; override marks a publish past a non-clean scan.
data={"name": name, "slug": slug_hint, "output_id": output_id, "override": "1" if override else "0"},
files={"bundle": ("app.tar.gz", bundle, "application/gzip")},
)
except httpx.HTTPError: