Skip to content

Commit 70e70eb

Browse files
author
Jonah Williams
authored
[flutter_tools] Catch all exception subtypes when unzipping a file (flutter#70967)
1 parent 2f567c3 commit 70e70eb

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

packages/flutter_tools/lib/src/cache.dart

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'dart:async';
66

7-
import 'package:archive/archive.dart';
87
import 'package:crypto/crypto.dart';
98
import 'package:file/memory.dart';
109
import 'package:meta/meta.dart';
@@ -15,7 +14,7 @@ import 'android/gradle_utils.dart';
1514
import 'base/common.dart';
1615
import 'base/error_handling_io.dart';
1716
import 'base/file_system.dart';
18-
import 'base/io.dart' show HttpClient, HttpClientRequest, HttpClientResponse, HttpHeaders, HttpStatus, ProcessException, SocketException;
17+
import 'base/io.dart' show HttpClient, HttpClientRequest, HttpClientResponse, HttpHeaders, HttpStatus, SocketException;
1918
import 'base/logger.dart';
2019
import 'base/net.dart';
2120
import 'base/os.dart' show OperatingSystemUtils;
@@ -1792,14 +1791,7 @@ class ArtifactUpdater {
17921791

17931792
try {
17941793
extractor(tempFile, location);
1795-
} on ProcessException {
1796-
retries -= 1;
1797-
if (retries == 0) {
1798-
rethrow;
1799-
}
1800-
_deleteIgnoringErrors(tempFile);
1801-
continue;
1802-
} on ArchiveException {
1794+
} on Exception {
18031795
retries -= 1;
18041796
if (retries == 0) {
18051797
rethrow;

packages/flutter_tools/test/general.shard/artifact_updater_test.dart

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'package:archive/archive.dart';
65
import 'package:file/memory.dart';
76
import 'package:file/src/interface/file.dart';
87
import 'package:file_testing/file_testing.dart';
@@ -314,7 +313,7 @@ void main() {
314313
'test message',
315314
Uri.parse('http:///test.zip'),
316315
fileSystem.currentDirectory.childDirectory('out'),
317-
), throwsA(isA<ProcessException>()));
316+
), throwsA(isA<Exception>()));
318317
expect(fileSystem.file('te,[/test'), isNot(exists));
319318
expect(fileSystem.file('out/test'), isNot(exists));
320319
});
@@ -338,7 +337,7 @@ void main() {
338337
'test message',
339338
Uri.parse('http:///test.zip'),
340339
fileSystem.currentDirectory.childDirectory('out'),
341-
), throwsA(isA<ArchiveException>()));
340+
), throwsA(isA<Exception>()));
342341
expect(fileSystem.file('te,[/test'), isNot(exists));
343342
expect(fileSystem.file('out/test'), isNot(exists));
344343
});
@@ -401,10 +400,7 @@ class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils {
401400
void unzip(File file, Directory targetDirectory) {
402401
if (failures > 0) {
403402
failures -= 1;
404-
if (windows) {
405-
throw ArchiveException('zip');
406-
}
407-
throw const ProcessException('zip', <String>[], 'Failed to unzip');
403+
throw Exception();
408404
}
409405
targetDirectory.childFile(file.fileSystem.path.basenameWithoutExtension(file.path))
410406
.createSync();
@@ -414,10 +410,7 @@ class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils {
414410
void unpack(File gzippedTarFile, Directory targetDirectory) {
415411
if (failures > 0) {
416412
failures -= 1;
417-
if (windows) {
418-
throw ArchiveException('zip');
419-
}
420-
throw const ProcessException('zip', <String>[], 'Failed to unzip');
413+
throw Exception();
421414
}
422415
targetDirectory.childFile(gzippedTarFile.fileSystem.path.basenameWithoutExtension(gzippedTarFile.path))
423416
.createSync();

0 commit comments

Comments
 (0)