Separate filesystem context from access

This commit is contained in:
2026-10-25 13:09:44 +00:00
parent 0d149e51f0
commit 6158e9db3b
5 changed files with 180 additions and 112 deletions

View File

@@ -76,36 +76,22 @@ func acquireImportedInput(request importAcquisitionRequest, policy *acquisitionP
source := request.input.input.source
context := request.input.input.filesystem
main := request.main
if nativeContext(source, context) {
access, basePath, mainPath, diagnostic := nativeFilesystemAccess(source, context)
if diagnostic != nil {
return nil, sourceInfos(main.source), []Diagnostic{*diagnostic}
}
native := source.namespace
if native == nil && context != nil && context.FS != nil {
native = context.FS.namespace
}
return acquireImportedWithAccess(request, policy, state, tier, access, resolvedFilesystemContext{
native: native, hostToken: tier.hostToken, rootPath: access.rootPath,
basePath: basePath, mainPath: mainPath,
})
}
rootPath, basePath, mainPath, diagnostic := importFilesystem(source, context, main)
resolved, diagnostic := resolveFilesystemContext(source, context, main, tier.hostToken)
if diagnostic != nil {
return nil, sourceInfos(main.source), []Diagnostic{*diagnostic}
}
access, err := openHostAccess(rootPath)
if resolved.native == nil {
if diagnostic := validateResolvedFilesystemDirectories(resolved); diagnostic != nil {
return nil, sourceInfos(main.source), []Diagnostic{*diagnostic}
}
}
access, err := openResolvedFilesystemAccess(resolved)
if err != nil {
diagnostic := globFilesystemDiagnostic(err, "configuration root could not be opened", Location{})
diagnostic.Primary = nil
return nil, sourceInfos(main.source), []Diagnostic{diagnostic}
}
if tier.hostToken != nil {
access.token = tier.hostToken
}
return acquireImportedWithAccess(request, policy, state, tier, access, resolvedFilesystemContext{
hostToken: tier.hostToken, rootPath: rootPath, basePath: basePath, mainPath: mainPath,
})
return acquireImportedWithAccess(request, policy, state, tier, access, resolved)
}
func acquireImportedWithAccess(request importAcquisitionRequest, policy *acquisitionPolicy, loadState *acquisitionState, tier *tierAcquisitionState, access *filesystemAccess, resolved resolvedFilesystemContext) (*composedDocument, []SourceInfo, []Diagnostic) {