Axolotl desktop CI / guardrails (push) Has been cancelled
Axolotl desktop CI / desktop (macos-latest) (push) Has been cancelled
Axolotl desktop CI / desktop (ubuntu-latest) (push) Has been cancelled
Axolotl desktop CI / desktop (windows-latest) (push) Has been cancelled
Axolotl desktop CI / website (push) Has been cancelled
Repository checks / typos (push) Has been cancelled
Repository checks / tombi (push) Has been cancelled
Rust checks / shear (push) Has been cancelled
Sync source to CNB / Sync Git ref (push) Has been cancelled
Sync LobeHub models / sync (push) Has been cancelled
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import type { InstallJobSnapshot } from './install.ts'
|
|
|
|
interface InstallRetryDependencies {
|
|
getInstanceMode: (instanceId: string) => Promise<'starlight' | 'local'>
|
|
retryHosted: (instanceId: string, sourceJobId: string) => Promise<void>
|
|
retryGeneric: (jobId: string) => Promise<InstallJobSnapshot>
|
|
}
|
|
|
|
/**
|
|
* Minecraft installation jobs started by StarLight synchronization are only
|
|
* one stage of the full operation. Retrying that stage alone leaves the
|
|
* pending pack journal unapplied, so these jobs must resume through
|
|
* `hostedSync` instead of the generic install-job retry command.
|
|
*/
|
|
export function hostedRuntimeRetryInstanceId(job: InstallJobSnapshot): string | null {
|
|
if (job.kind !== 'install_existing_instance' || job.instance_deleted) return null
|
|
return job.instance_id ?? job.target.instance_id ?? null
|
|
}
|
|
|
|
export function hostedRetryRoute(instanceId: string): string {
|
|
return `/instance/${encodeURIComponent(instanceId)}`
|
|
}
|
|
|
|
export async function retryInstallJob(
|
|
job: InstallJobSnapshot,
|
|
dependencies: InstallRetryDependencies,
|
|
): Promise<InstallJobSnapshot | null> {
|
|
const instanceId = hostedRuntimeRetryInstanceId(job)
|
|
if (instanceId && (await dependencies.getInstanceMode(instanceId)) === 'starlight') {
|
|
await dependencies.retryHosted(instanceId, job.job_id)
|
|
return null
|
|
}
|
|
return dependencies.retryGeneric(job.job_id)
|
|
}
|