[flutter_tools] fix failure to create ansi spinner if download needs to be retried (#65797)

Because the Status spinner was only created on setup, the second stop would asset/crash.

Fixes #65449
This commit is contained in:
Jonah Williams
2020-09-14 17:55:11 -07:00
committed by GitHub
parent 4e20f00053
commit 6acea15f22
3 changed files with 47 additions and 6 deletions

View File

@@ -81,7 +81,10 @@ class OutputPreferences {
/// The command line terminal, if available.
abstract class Terminal {
factory Terminal.test() = _TestTerminal;
/// Create a new test [Terminal].
///
/// If not specified, [supportsColor] defaults to `false`.
factory Terminal.test({bool supportsColor}) = _TestTerminal;
/// Whether the current terminal supports color escape codes.
bool get supportsColor;
@@ -300,6 +303,8 @@ class AnsiTerminal implements Terminal {
}
class _TestTerminal implements Terminal {
_TestTerminal({this.supportsColor = false});
@override
bool usesTerminalUi;
@@ -329,7 +334,7 @@ class _TestTerminal implements Terminal {
set singleCharMode(bool value) { }
@override
bool get supportsColor => false;
final bool supportsColor;
@override
bool get supportsEmoji => false;

View File

@@ -1466,13 +1466,14 @@ class ArtifactUpdater {
) async {
final String downloadPath = flattenNameSubdirs(url, _fileSystem);
final File tempFile = _createDownloadFile(downloadPath);
final Status status = _logger.startProgress(
message,
timeout: null, // This will take a variable amount of time based on network connectivity.
);
Status status;
int retries = _kRetryCount;
while (retries > 0) {
status = _logger.startProgress(
message,
timeout: null, // This will take a variable amount of time based on network connectivity.
);
try {
_ensureExists(tempFile.parent);
final IOSink ioSink = tempFile.openWrite();