mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-22 17:44:53 +02:00
[eric] publish: send output_id + override to cloud so republish reuses the slug
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user