at main 696 B view raw
1// SPDX-FileCopyrightText: 2025 The Project Pterodactyl Developers 2// 3// SPDX-License-Identifier: MPL-2.0 4 5import Foundation 6import llbuild2fx 7 8extension Keys.SourceTree { 9 struct GetUnitMap: BuildKey { 10 let sourceTreeId: LLBDataID 11 12 typealias ValueType = UnitMap 13 14 func computeValue(_ ctx: BuildContext<Self>) async throws -> UnitMap { 15 let sourceTree = try await LLBCASFileTree.load(id: sourceTreeId, in: ctx) 16 var units: [UnitName: UnitInfo] = [:] 17 try await sourceTree.traverse(root: .root, in: ctx) { path, blobID, directoryEntry in 18 let unitName = UnitName.fromPath(path) 19 units[unitName] = UnitInfo(path: path, blobId: blobID) 20 } 21 22 return UnitMap(units: units) 23 } 24 } 25}