MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / startShellIndexSync

Function startShellIndexSync

desktop/pi-threads/shell-index.ts:24–50  ·  view source on GitHub ↗
(
  cwd: string,
  options: { emitRefreshEvent?: boolean | undefined; warningLabel: string },
)

Source from the content-addressed store, hash-verified

22}
23
24function startShellIndexSync(
25 cwd: string,
26 options: { emitRefreshEvent?: boolean | undefined; warningLabel: string },
27) {
28 const syncPromise = syncShellIndex(cwd)
29 .then((syncResult) => {
30 if (syncResult.complete) {
31 syncedShellIndexes.add(cwd)
32 }
33
34 if (syncResult.didSync && (options.emitRefreshEvent ?? true)) {
35 emitDesktopEvent({ type: 'shell-state-refresh' })
36 }
37
38 return syncResult.complete
39 })
40 .catch((error) => {
41 console.warn(options.warningLabel, error)
42 return false
43 })
44 .finally(() => {
45 inFlightShellIndexSyncs.delete(cwd)
46 })
47
48 inFlightShellIndexSyncs.set(cwd, syncPromise)
49 return syncPromise
50}
51
52export function scheduleShellIndexSync(cwd: string) {
53 if (syncedShellIndexes.has(cwd) || inFlightShellIndexSyncs.has(cwd)) {

Callers 2

scheduleShellIndexSyncFunction · 0.85
refreshShellIndexFunction · 0.85

Calls 2

emitDesktopEventFunction · 0.90
syncShellIndexFunction · 0.85

Tested by

no test coverage detected