getModelFilePaths method
Gets the file paths for an installed model
Implementation
@override
Future<Map<String, String>?> getModelFilePaths(ModelSpec spec) async {
await _ensureInitialized();
// Phase 5: Delegate to Modern API
final registry = ServiceRegistry.instance;
final repository = registry.modelRepository;
final fileSystem = registry.fileSystemService as WebFileSystemService;
// Check installation via repository
bool allFilesInstalled = true;
for (final file in spec.files) {
if (!await repository.isInstalled(file.filename)) {
allFilesInstalled = false;
break;
}
}
if (!allFilesInstalled) {
return null;
}
final filePaths = <String, String>{};
for (final file in spec.files) {
// Get URL from WebFileSystemService based on source type
final String path;
if (file.source is NetworkSource) {
// Web: Get registered URL
path = fileSystem.getUrl(file.filename) ?? (file.source as NetworkSource).url;
} else if (file.source is BundledSource) {
// Web: Bundled resources
path = await fileSystem.getBundledResourcePath((file.source as BundledSource).resourceName);
} else if (file.source is AssetSource) {
// Web: Asset path
path = (file.source as AssetSource).normalizedPath;
} else if (file.source is FileSource) {
// Web: External URL or registered path
final fileSource = file.source as FileSource;
path = fileSystem.getUrl(file.filename) ?? fileSource.path;
} else {
// Fallback: use getTargetPath
path = await fileSystem.getTargetPath(file.filename);
}
filePaths[file.prefsKey] = path;
}
return filePaths.isNotEmpty ? filePaths : null;
}