Preserve failing search candidate diagnostics
This commit is contained in:
@@ -483,8 +483,23 @@ func defaultDiscoveryHostProbe() discoveryHostProbe {
|
||||
return discoveryHostProbe{evalSymlinks: filepath.EvalSymlinks, stat: os.Stat}
|
||||
}
|
||||
|
||||
// resolveSearchInput associates a terminal candidate failure with the same file
|
||||
// evidence as ordinary acquisition. Exhaustion and base failures have no file.
|
||||
func resolveSearchInput(source Source, sourceID string, helpers discoveryDirectoryHelpers, probe discoveryHostProbe) (Source, *SourceInfo, []Diagnostic) {
|
||||
selected, diagnostics := resolveSearchSource(source, source.search, source.searchApp, source.searchRequired, helpers, probe)
|
||||
if len(diagnostics) == 0 || selected.kind != sourceFile {
|
||||
return selected, nil, diagnostics
|
||||
}
|
||||
info := &SourceInfo{ID: sourceID, Label: selected.label, Path: selected.path, Layer: LayerBase, Kind: SourceKindFile}
|
||||
for index := range diagnostics {
|
||||
diagnostics[index].Primary = &Location{SourceID: sourceID}
|
||||
}
|
||||
return selected, info, diagnostics
|
||||
}
|
||||
|
||||
// resolveSearchSource selects one ordinary file source. A nil description leaves
|
||||
// an existing source untouched; the selected file is read later by readSource.
|
||||
// A terminal candidate failure returns its file descriptor for error evidence.
|
||||
func resolveSearchSource(source Source, description *Search, application string, required bool, helpers discoveryDirectoryHelpers, probe discoveryHostProbe) (Source, []Diagnostic) {
|
||||
if description == nil {
|
||||
return source, nil
|
||||
@@ -519,13 +534,15 @@ func resolveSearchSource(source Source, description *Search, application string,
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
continue
|
||||
}
|
||||
return Source{}, []Diagnostic{classifySourceError(err, "")}
|
||||
return File(candidate), []Diagnostic{classifySourceError(err, "")}
|
||||
}
|
||||
if _, err := probe.stat(canonical); err != nil {
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
continue
|
||||
}
|
||||
return Source{}, []Diagnostic{classifySourceError(err, "")}
|
||||
failed := File(candidate)
|
||||
failed.path = canonical
|
||||
return failed, []Diagnostic{classifySourceError(err, "")}
|
||||
}
|
||||
return File(candidate), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user