mirror of
https://gitee.com/zhangsken/opencode.git
synced 2026-10-16 10:30:01 +08:00
fix(updates): scope minimum checks to the caller channel
This commit is contained in:
@@ -17,6 +17,10 @@ release preserves the minimum marker.
|
||||
Clients send their running version as `?current=<version>` and use the CLI's default
|
||||
`User-Agent: opencode/<channel>/<version>/cli`. When `current` is absent, the service
|
||||
parses that User-Agent or the older `opencode/<version>` format.
|
||||
The caller's channel comes from the default User-Agent, or from a preview version
|
||||
such as `0.0.0-beta-18955` when that channel is absent. If an identified caller channel
|
||||
differs from the requested channel, the service serves the active release without
|
||||
applying the minimum. Historical `next` and `beta` count as the same channel.
|
||||
A caller below the minimum receives that exact
|
||||
artifact; callers at or above it receive the active artifact. An unparseable caller
|
||||
version receives the minimum. Requests with neither version source receive the active
|
||||
|
||||
@@ -70,11 +70,13 @@ export default {
|
||||
}
|
||||
|
||||
const resolved = resolveChannel(path[0])
|
||||
const agent = request.headers.get("User-Agent")?.match(/^opencode\/(?:[^/]+\/([^/]+)\/cli|(.*))$/)
|
||||
const current = url.searchParams.get("current") ?? agent?.[1] ?? agent?.[2]
|
||||
if (path.length === 1) return channel(env.DB, resolved, current)
|
||||
if (path.length === 2) return artifactName(env.DB, resolved, path[1], current)
|
||||
return artifactDistribution(env.DB, resolved, path[1], path[2], current)
|
||||
const agent = request.headers.get("User-Agent")?.match(/^opencode\/(?:([^/]+)\/([^/]+)\/cli|(.*))$/)
|
||||
const current = url.searchParams.get("current") ?? agent?.[2] ?? agent?.[3]
|
||||
const source = agent?.[1] ?? current?.match(/^v?0\.0\.0-(.+)-\d+(?:\.\d+)?(?:\+.*)?$/)?.[1]
|
||||
const caller = source === undefined || resolveChannel(source) === resolved ? current : undefined
|
||||
if (path.length === 1) return channel(env.DB, resolved, caller)
|
||||
if (path.length === 2) return artifactName(env.DB, resolved, path[1], caller)
|
||||
return artifactDistribution(env.DB, resolved, path[1], path[2], caller)
|
||||
},
|
||||
} satisfies ExportedHandler<Env>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user