load method
Load the pool.
Implementation
Future<void> load() async {
final catalogDirPrefixes = ['/usr/share', '/var/lib', '/var/cache'];
var catalogDirs = [];
for (var prefix in catalogDirPrefixes) {
var catalogPath = '$prefix/swcatalog';
var catalogLegacyPath = '$prefix/app-info';
// Only use the legacy path if it's not a symlink to the current path.
var ignoreLegacyPath = false;
var legacyLink = Link(catalogLegacyPath);
ignoreLegacyPath =
await legacyLink.exists() && await legacyLink.target() == catalogPath;
catalogDirs.add(catalogPath);
if (!ignoreLegacyPath) {
catalogDirs.add(catalogLegacyPath);
}
}
var collectionFutures = <Future<AppstreamCollection>>[];
for (var dir in catalogDirs) {
var xmlPaths = await _listFiles(dir, ['.xml', '.xml.gz']);
for (var path in xmlPaths) {
collectionFutures.add(_loadXmlCollection(path));
}
var yamlPaths = await _listFiles('$dir/yaml', ['.yml', '.yml.gz']);
for (var path in yamlPaths) {
collectionFutures.add(_loadYamlCollection(path));
}
}
var collections = await Future.wait(collectionFutures);
for (var collection in collections) {
components.addAll(collection.components);
}
}