Unverified Commit 851ff687 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] throwToolExit from archive failure (#74259)

parent 80142d45
...@@ -1793,10 +1793,14 @@ class ArtifactUpdater { ...@@ -1793,10 +1793,14 @@ class ArtifactUpdater {
try { try {
extractor(tempFile, location); extractor(tempFile, location);
} on Exception { } on Exception catch (err) {
retries -= 1; retries -= 1;
if (retries == 0) { 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); _deleteIgnoringErrors(tempFile);
continue; continue;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:file/src/interface/file.dart'; import 'package:file/src/interface/file.dart';
import 'package:file_testing/file_testing.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/file_system.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
...@@ -246,7 +247,7 @@ void main() { ...@@ -246,7 +247,7 @@ void main() {
expect(fileSystem.file('out/test'), isNot(exists)); 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 MockOperatingSystemUtils operatingSystemUtils = MockOperatingSystemUtils();
final MemoryFileSystem fileSystem = MemoryFileSystem.test(); final MemoryFileSystem fileSystem = MemoryFileSystem.test();
final BufferLogger logger = BufferLogger.test(); final BufferLogger logger = BufferLogger.test();
...@@ -294,7 +295,7 @@ void main() { ...@@ -294,7 +295,7 @@ void main() {
expect(fileSystem.file('out/test'), exists); 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 MockOperatingSystemUtils operatingSystemUtils = MockOperatingSystemUtils();
final MemoryFileSystem fileSystem = MemoryFileSystem.test(); final MemoryFileSystem fileSystem = MemoryFileSystem.test();
final BufferLogger logger = BufferLogger.test(); final BufferLogger logger = BufferLogger.test();
...@@ -313,7 +314,7 @@ void main() { ...@@ -313,7 +314,7 @@ void main() {
'test message', 'test message',
Uri.parse('http:///test.zip'), Uri.parse('http:///test.zip'),
fileSystem.currentDirectory.childDirectory('out'), fileSystem.currentDirectory.childDirectory('out'),
), throwsA(isA<Exception>())); ), throwsA(isA<ToolExit>()));
expect(fileSystem.file('te,[/test'), isNot(exists)); expect(fileSystem.file('te,[/test'), isNot(exists));
expect(fileSystem.file('out/test'), isNot(exists)); expect(fileSystem.file('out/test'), isNot(exists));
}); });
...@@ -337,7 +338,7 @@ void main() { ...@@ -337,7 +338,7 @@ void main() {
'test message', 'test message',
Uri.parse('http:///test.zip'), Uri.parse('http:///test.zip'),
fileSystem.currentDirectory.childDirectory('out'), fileSystem.currentDirectory.childDirectory('out'),
), throwsA(isA<Exception>())); ), throwsA(isA<ToolExit>()));
expect(fileSystem.file('te,[/test'), isNot(exists)); expect(fileSystem.file('te,[/test'), isNot(exists));
expect(fileSystem.file('out/test'), isNot(exists)); expect(fileSystem.file('out/test'), isNot(exists));
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment