MCPcopy Create free account
hub / github.com/JordanCoin/codemap / getHubInfoWithFallback

Function getHubInfoWithFallback

cmd/hooks.go:110–144  ·  view source on GitHub ↗
(root string, allowFallback bool)

Source from the content-addressed store, hash-verified

108}
109
110func getHubInfoWithFallback(root string, allowFallback bool) *hubInfo {
111 if state := watch.ReadState(root); state != nil {
112 // State may contain file/event info only (no dependency graph) on very
113 // large repos. Avoid expensive fallback scans in that case.
114 if len(state.Importers) == 0 && len(state.Imports) == 0 && len(state.Hubs) == 0 {
115 return nil
116 }
117 return &hubInfo{
118 Hubs: state.Hubs,
119 Importers: state.Importers,
120 Imports: state.Imports,
121 }
122 }
123
124 if !allowFallback {
125 return nil
126 }
127
128 // If daemon is running but state is unavailable, skip expensive fallback.
129 if watch.IsRunning(root) {
130 return nil
131 }
132
133 // Fall back to fresh scan only when daemon is not running.
134 fg, err := scanner.BuildFileGraph(root)
135 if err != nil {
136 return nil
137 }
138
139 return &hubInfo{
140 Hubs: fg.HubFiles(),
141 Importers: fg.Importers,
142 Imports: fg.Imports,
143 }
144}
145
146// RunHookWithTimeout executes a hook with a hard timeout.
147// On timeout, returns HookTimeoutError and callers should fail open.

Callers 2

getHubInfoFunction · 0.85
getHubInfoNoFallbackFunction · 0.85

Calls 4

ReadStateFunction · 0.92
IsRunningFunction · 0.92
BuildFileGraphFunction · 0.92
HubFilesMethod · 0.80

Tested by

no test coverage detected