mirror of
https://github.com/MeshEnvy/mesh-forge.git
synced 2026-05-04 20:42:43 +02:00
feat: add sourceUrl support for build status updates and downloads
This commit is contained in:
@@ -239,6 +239,7 @@ export const updateBuildStatus = internalMutation({
|
||||
'status',
|
||||
'completedAt',
|
||||
'artifactPath',
|
||||
'sourceUrl',
|
||||
'githubRunId',
|
||||
]),
|
||||
buildId: v.id('builds'),
|
||||
@@ -249,6 +250,7 @@ export const updateBuildStatus = internalMutation({
|
||||
|
||||
const updateData: BuildUpdateData & {
|
||||
artifactPath?: string
|
||||
sourceUrl?: string
|
||||
githubRunId?: number
|
||||
} = {
|
||||
status: args.status,
|
||||
@@ -264,6 +266,11 @@ export const updateBuildStatus = internalMutation({
|
||||
updateData.artifactPath = args.artifactPath
|
||||
}
|
||||
|
||||
// Set sourceUrl if provided
|
||||
if (args.sourceUrl !== undefined) {
|
||||
updateData.sourceUrl = args.sourceUrl
|
||||
}
|
||||
|
||||
// Set githubRunId if provided
|
||||
if (args.githubRunId !== undefined) {
|
||||
updateData.githubRunId = args.githubRunId
|
||||
@@ -433,7 +440,16 @@ export const generateSourceDownloadUrl = mutation({
|
||||
const build = await ctx.db.get(args.buildId)
|
||||
if (!build) throw new Error('Build not found')
|
||||
|
||||
const objectKey = `${build.buildHash}.tar.gz`
|
||||
// Use sourceUrl if available, otherwise fall back to constructing from buildHash
|
||||
let objectKey: string
|
||||
if (build.sourceUrl) {
|
||||
// Remove leading slash if present
|
||||
objectKey = build.sourceUrl.startsWith('/')
|
||||
? build.sourceUrl.substring(1)
|
||||
: build.sourceUrl
|
||||
} else {
|
||||
objectKey = `${build.buildHash}.tar.gz`
|
||||
}
|
||||
|
||||
return await generateAuthenticatedDownloadUrl(
|
||||
ctx,
|
||||
@@ -454,7 +470,16 @@ export const generateAnonymousSourceDownloadUrl = mutation({
|
||||
slug: v.string(),
|
||||
},
|
||||
handler: async (_ctx, args) => {
|
||||
const objectKey = `${args.build.buildHash}.tar.gz`
|
||||
// Use sourceUrl if available, otherwise fall back to constructing from buildHash
|
||||
let objectKey: string
|
||||
if (args.build.sourceUrl) {
|
||||
// Remove leading slash if present
|
||||
objectKey = args.build.sourceUrl.startsWith('/')
|
||||
? args.build.sourceUrl.substring(1)
|
||||
: args.build.sourceUrl
|
||||
} else {
|
||||
objectKey = `${args.build.buildHash}.tar.gz`
|
||||
}
|
||||
|
||||
return await generateAnonymousDownloadUrlHelper(
|
||||
args.build,
|
||||
|
||||
@@ -53,6 +53,7 @@ http.route({
|
||||
buildId: payload.build_id,
|
||||
status: payload.state,
|
||||
artifactPath: payload.artifactPath,
|
||||
sourceUrl: payload.sourcePath,
|
||||
githubRunId,
|
||||
})
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ export const buildFields = {
|
||||
// Optional props
|
||||
completedAt: v.optional(v.number()),
|
||||
artifactPath: v.optional(v.string()),
|
||||
sourceUrl: v.optional(v.string()),
|
||||
githubRunId: v.optional(v.number()),
|
||||
}
|
||||
|
||||
|
||||
@@ -220,6 +220,11 @@ export default function BuildProgress() {
|
||||
{downloadError && (
|
||||
<p className="text-sm text-red-400">{downloadError}</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{build.sourceUrl && (
|
||||
<div className="space-y-2">
|
||||
<Button
|
||||
onClick={handleSourceDownload}
|
||||
className="w-full bg-slate-700 hover:bg-slate-600"
|
||||
|
||||
@@ -240,6 +240,11 @@ export default function ProfileFlash() {
|
||||
>
|
||||
Download Firmware
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{build.sourceUrl && (
|
||||
<div className="space-y-2">
|
||||
<Button
|
||||
onClick={handleSourceDownload}
|
||||
className="bg-slate-700 hover:bg-slate-600 w-full"
|
||||
|
||||
Reference in New Issue
Block a user