MCPcopy Index your code
hub / github.com/WendellCraft/ModpackDebuggerKit / runDebugScan

Method runDebugScan

debug.go:113–189  ·  view source on GitHub ↗
(modsToTest []string)

Source from the content-addressed store, hash-verified

111}
112
113func (a *App) runDebugScan(modsToTest []string) {
114 a.mu.Lock()
115 a.ActiveScan = true
116 a.ScanCancelled = false
117 a.CurrentTestGroup = modsToTest
118 modsDir := a.ProjectData.ModsDir
119 a.mu.Unlock()
120
121 a.emitLog(fmt.Sprintf("Starting debug scan with %d mods...", len(modsToTest)), LogInfo)
122 a.emitLog("Preparing... (moving mods to temp directory)", LogInfo)
123
124 for i, mod := range modsToTest {
125 if a.getScanCancelled() {
126 break
127 }
128 src := filepath.Join(modsDir, mod)
129 dst := filepath.Join(a.TempDir, mod)
130 if _, err := os.Stat(src); err == nil {
131 if err := moveFile(src, dst); err != nil {
132 a.emitLog("Failed to move "+mod+": "+err.Error(), LogError)
133 a.restoreAllMods(modsDir)
134 a.mu.Lock()
135 a.ActiveScan = false
136 a.CurrentTestGroup = nil
137 a.mu.Unlock()
138 wailsRuntime.EventsEmit(a.ctx, "debug-failed", nil)
139 return
140 }
141 }
142 a.emitLog(fmt.Sprintf("Moving... (%d/%d)", i+1, len(modsToTest)), LogProgress)
143 }
144
145 var culpritInfo string
146 if !a.getScanCancelled() {
147 a.emitLog("Preparation complete.", LogSuccess)
148 a.emitLog("Analyzing mod dependencies to form testable groups...", LogInfo)
149 primaryMods, groupMap := a.getPrimaryModsAndGroupMap(modsToTest)
150 a.emitLog(fmt.Sprintf("Identified %d primary mods/groups for testing.", len(primaryMods)), LogSuccess)
151
152 if len(primaryMods) > 0 {
153 a.emitLog("Starting debug search to isolate 1 culprit...", LogInfo)
154 culpritInfo = a.binarySearch(primaryMods, groupMap, 1)
155
156 if culpritInfo == "" && !a.getScanCancelled() {
157 a.emitLog("Unable to isolate a single culprit. Falling back to 2-culprit resolution...", LogWarning)
158 wailsRuntime.EventsEmit(a.ctx, "test-fallback", "Unable to isolate a single problematic mod/group.\n\nFalling back to identify an interaction between 2.")
159 culpritInfo = a.binarySearch(primaryMods, groupMap, 2)
160 }
161 if culpritInfo == "" && !a.getScanCancelled() {
162 a.emitLog("Unable to isolate 2 culprits. Falling back to 3-culprit resolution...", LogWarning)
163 wailsRuntime.EventsEmit(a.ctx, "test-fallback", "Unable to isolate a 2-mod/group interaction.\n\nFalling back to identify an interaction between 3.")
164 culpritInfo = a.binarySearch(primaryMods, groupMap, 3)
165 }
166 } else {
167 a.emitLog("No primary mods could be identified. Aborting scan.", LogError)
168 }
169 }
170

Callers 1

StartDebugMethod · 0.95

Calls 6

emitLogMethod · 0.95
getScanCancelledMethod · 0.95
restoreAllModsMethod · 0.95
binarySearchMethod · 0.95
moveFileFunction · 0.85

Tested by

no test coverage detected