[flutter_tools] throwToolExit from archive failure (#74259)

This commit is contained in:
Jonah Williams
2021-01-20 15:17:58 -08:00
committed by GitHub
parent 80142d4560
commit 851ff68788
2 changed files with 11 additions and 6 deletions

View File

@@ -1793,10 +1793,14 @@ class ArtifactUpdater {
try {
extractor(tempFile, location);
} on Exception {
} on Exception catch (err) {
retries -= 1;
if (retries == 0) {
rethrow;
throwToolExit(
'Flutter could not download and/or extract $url. Ensure you have '
'network connectivity and all of the required dependencies listed at'
'flutter.dev/setup.\nThe original exception was: $err.'
);
}
_deleteIgnoringErrors(tempFile);
continue;

View File

@@ -5,6 +5,7 @@
import 'package:file/memory.dart';
import 'package:file/src/interface/file.dart';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
@@ -246,7 +247,7 @@ void main() {
expect(fileSystem.file('out/test'), isNot(exists));
});
testWithoutContext('ArtifactUpdater will de-download a file if unzipping fails', () async {
testWithoutContext('ArtifactUpdater will re-download a file if unzipping fails', () async {
final MockOperatingSystemUtils operatingSystemUtils = MockOperatingSystemUtils();
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
final BufferLogger logger = BufferLogger.test();
@@ -294,7 +295,7 @@ void main() {
expect(fileSystem.file('out/test'), exists);
});
testWithoutContext('ArtifactUpdater will bail if unzipping fails more than twice', () async {
testWithoutContext('ArtifactUpdater will bail with a tool exit if unzipping fails more than twice', () async {
final MockOperatingSystemUtils operatingSystemUtils = MockOperatingSystemUtils();
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
final BufferLogger logger = BufferLogger.test();
@@ -313,7 +314,7 @@ void main() {
'test message',
Uri.parse('http:///test.zip'),
fileSystem.currentDirectory.childDirectory('out'),
), throwsA(isA<Exception>()));
), throwsA(isA<ToolExit>()));
expect(fileSystem.file('te,[/test'), isNot(exists));
expect(fileSystem.file('out/test'), isNot(exists));
});
@@ -337,7 +338,7 @@ void main() {
'test message',
Uri.parse('http:///test.zip'),
fileSystem.currentDirectory.childDirectory('out'),
), throwsA(isA<Exception>()));
), throwsA(isA<ToolExit>()));
expect(fileSystem.file('te,[/test'), isNot(exists));
expect(fileSystem.file('out/test'), isNot(exists));
});