MCPcopy Create free account
hub / github.com/Y80/bmm / startCheckHostsTask

Function startCheckHostsTask

src/controllers/BookmarkHostCheck.controller.ts:380–409  ·  view source on GitHub ↗
(input: {
  getRunningTask: () => Promise<CheckHostsTaskValue | null>
  getHostKeys: () => Promise<Array<{ hostKey: string | null }>>
  saveTask: SaveCheckHostsTask
})

Source from the content-addressed store, hash-verified

378}
379
380async function startCheckHostsTask(input: {
381 getRunningTask: () => Promise<CheckHostsTaskValue | null>
382 getHostKeys: () => Promise<Array<{ hostKey: string | null }>>
383 saveTask: SaveCheckHostsTask
384}) {
385 const runningTask = await input.getRunningTask()
386 if (runningTask && runningTask.finishedAt === null) return runningTask
387
388 const rows = await input.getHostKeys()
389 const hostKeys = await filterPendingHostKeys(rows.map((item) => item.hostKey))
390 const now = new Date().toISOString()
391 const initialTask: CheckHostsTaskValue = {
392 startedAt: now,
393 finishedAt: hostKeys.length ? null : now,
394 total: hostKeys.length,
395 checked: 0,
396 errorMessage: null,
397 }
398
399 await input.saveTask(initialTask)
400 if (hostKeys.length) {
401 void executeCheckHostsTask({
402 hostKeys,
403 initialTask,
404 saveTask: input.saveTask,
405 })
406 }
407
408 return initialTask
409}
410
411const BookmarkHostCheckController = {
412 async checkHost(hostKey: string, opts: { timeout?: number; proxyUrl?: string } = {}) {

Callers 2

startUserCheckHostsTaskFunction · 0.70

Calls 2

filterPendingHostKeysFunction · 0.85
executeCheckHostsTaskFunction · 0.85

Tested by

no test coverage detected