[flutter_tools] do not crash validator if intellij JAR file is missing (#67931)

This failure has been happening for a while but was covered by the overly broad catch. Removing that revealed that newer intellij versions have a different plugins file. The tool still can't find the file, but it won't crash now

Fixes #67918
This commit is contained in:
Jonah Williams
2020-10-12 10:34:05 -07:00
committed by GitHub
parent 7668f06ffe
commit b4e4e8d965
2 changed files with 28 additions and 4 deletions

View File

@@ -73,11 +73,14 @@ class IntelliJPlugins {
final String jarPath = packageName.endsWith('.jar')
? _fileSystem.path.join(pluginsPath, packageName)
: _fileSystem.path.join(pluginsPath, packageName, 'lib', '$packageName.jar');
final File file = _fileSystem.file(jarPath);
if (!file.existsSync()) {
return null;
}
try {
final Archive archive =
ZipDecoder().decodeBytes(_fileSystem.file(jarPath).readAsBytesSync());
final ArchiveFile file = archive.findFile('META-INF/plugin.xml');
final String content = utf8.decode(file.content as List<int>);
final Archive archive = ZipDecoder().decodeBytes(file.readAsBytesSync());
final ArchiveFile archiveFile = archive.findFile('META-INF/plugin.xml');
final String content = utf8.decode(archiveFile.content as List<int>);
const String versionStartTag = '<version>';
final int start = content.indexOf(versionStartTag);
final int end = content.indexOf('</version>', start);