Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/worker/src/jobs/service.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1622,6 +1622,7 @@ test('getJobInspection returns persisted params after a job update', async () =>
},
})

repoMockModule.syncArtifactSourceSnapshot.mockClear()
const updated = await updateJob({
env,
callerContext,
Expand All @@ -1640,6 +1641,7 @@ test('getJobInspection returns persisted params after a job update', async () =>

expect(updated.params).toEqual({ bridgeId: 'ZPGI01117' })
expect(inspected.job.params).toEqual({ bridgeId: 'ZPGI01117' })
expect(repoMockModule.syncArtifactSourceSnapshot).not.toHaveBeenCalled()
})

test('executeJobOnce binds scheduled jobs to writable storage', async () => {
Expand Down
37 changes: 24 additions & 13 deletions packages/worker/src/jobs/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,15 @@ function resolveUpdatedShape(input: {
}
}

function shouldSyncJobSourceForUpdate(body: JobUpdateInput) {
return (
body.code !== undefined ||
body.name !== undefined ||
body.schedule !== undefined ||
body.timezone !== undefined
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

export async function createJob(input: {
env: Env
callerContext: McpCallerContext
Expand Down Expand Up @@ -1131,19 +1140,21 @@ export async function updateJob(input: {
})
: existing.nextRunAt,
}
const syncedPublishedCommit = await syncArtifactSourceSnapshot({
env: input.env,
userId: callerContext.user.userId,
baseUrl: callerContext.baseUrl,
sourceId: updated.sourceId,
bootstrapAccess: null,
files: buildJobSourceFiles({
job: toJobView(updated),
moduleSource: shape.moduleSource ?? null,
}),
})
if (syncedPublishedCommit) {
updated.publishedCommit = syncedPublishedCommit
if (shouldSyncJobSourceForUpdate(input.body)) {
const syncedPublishedCommit = await syncArtifactSourceSnapshot({
env: input.env,
userId: callerContext.user.userId,
baseUrl: callerContext.baseUrl,
sourceId: updated.sourceId,
bootstrapAccess: null,
files: buildJobSourceFiles({
job: toJobView(updated),
moduleSource: shape.moduleSource ?? null,
}),
})
if (syncedPublishedCommit) {
updated.publishedCommit = syncedPublishedCommit
}
}
const nextCallerContextJson = serializeCallerContext(callerContext)
const didUpdate = await updateJobRow({
Expand Down
Loading