load static method
Loads a complete inventory using OKF's symlink and parse protections. No store mutation occurs until the entire snapshot has been read.
Implementation
static Future<KnowledgeSnapshot> load(
String root, {
required String bundleId,
int maxChunkLength = 1000,
}) async {
final loaded = await const OkfBundleLoader().inspect(root);
if (loaded.hasFindings) throw OkfBundleLoadException(loaded);
final sources = <String, String>{...loaded.indexes, ...loaded.logs};
for (final path in loaded.documents.keys) {
final file = File(p.joinAll([loaded.rootPath, ...p.posix.split(path)]));
if (await FileSystemEntity.type(file.path, followLinks: false) !=
FileSystemEntityType.file) {
throw FileSystemException('Concept changed during loading', path);
}
sources[path] = await file.readAsString();
}
return KnowledgeSnapshot.fromSources(
sources,
bundleId: bundleId,
assets: loaded.assets,
maxChunkLength: maxChunkLength,
);
}