mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[flutter_tools] Catch all exception subtypes when unzipping a file (#70967)
This commit is contained in:
parent
2f567c39a6
commit
70e70ebb62
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:archive/archive.dart';
|
|
||||||
import 'package:crypto/crypto.dart';
|
import 'package:crypto/crypto.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
@ -15,7 +14,7 @@ import 'android/gradle_utils.dart';
|
|||||||
import 'base/common.dart';
|
import 'base/common.dart';
|
||||||
import 'base/error_handling_io.dart';
|
import 'base/error_handling_io.dart';
|
||||||
import 'base/file_system.dart';
|
import 'base/file_system.dart';
|
||||||
import 'base/io.dart' show HttpClient, HttpClientRequest, HttpClientResponse, HttpHeaders, HttpStatus, ProcessException, SocketException;
|
import 'base/io.dart' show HttpClient, HttpClientRequest, HttpClientResponse, HttpHeaders, HttpStatus, SocketException;
|
||||||
import 'base/logger.dart';
|
import 'base/logger.dart';
|
||||||
import 'base/net.dart';
|
import 'base/net.dart';
|
||||||
import 'base/os.dart' show OperatingSystemUtils;
|
import 'base/os.dart' show OperatingSystemUtils;
|
||||||
@ -1792,14 +1791,7 @@ class ArtifactUpdater {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
extractor(tempFile, location);
|
extractor(tempFile, location);
|
||||||
} on ProcessException {
|
} on Exception {
|
||||||
retries -= 1;
|
|
||||||
if (retries == 0) {
|
|
||||||
rethrow;
|
|
||||||
}
|
|
||||||
_deleteIgnoringErrors(tempFile);
|
|
||||||
continue;
|
|
||||||
} on ArchiveException {
|
|
||||||
retries -= 1;
|
retries -= 1;
|
||||||
if (retries == 0) {
|
if (retries == 0) {
|
||||||
rethrow;
|
rethrow;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:archive/archive.dart';
|
|
||||||
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';
|
||||||
@ -314,7 +313,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<ProcessException>()));
|
), throwsA(isA<Exception>()));
|
||||||
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));
|
||||||
});
|
});
|
||||||
@ -338,7 +337,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<ArchiveException>()));
|
), throwsA(isA<Exception>()));
|
||||||
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));
|
||||||
});
|
});
|
||||||
@ -401,10 +400,7 @@ class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils {
|
|||||||
void unzip(File file, Directory targetDirectory) {
|
void unzip(File file, Directory targetDirectory) {
|
||||||
if (failures > 0) {
|
if (failures > 0) {
|
||||||
failures -= 1;
|
failures -= 1;
|
||||||
if (windows) {
|
throw Exception();
|
||||||
throw ArchiveException('zip');
|
|
||||||
}
|
|
||||||
throw const ProcessException('zip', <String>[], 'Failed to unzip');
|
|
||||||
}
|
}
|
||||||
targetDirectory.childFile(file.fileSystem.path.basenameWithoutExtension(file.path))
|
targetDirectory.childFile(file.fileSystem.path.basenameWithoutExtension(file.path))
|
||||||
.createSync();
|
.createSync();
|
||||||
@ -414,10 +410,7 @@ class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils {
|
|||||||
void unpack(File gzippedTarFile, Directory targetDirectory) {
|
void unpack(File gzippedTarFile, Directory targetDirectory) {
|
||||||
if (failures > 0) {
|
if (failures > 0) {
|
||||||
failures -= 1;
|
failures -= 1;
|
||||||
if (windows) {
|
throw Exception();
|
||||||
throw ArchiveException('zip');
|
|
||||||
}
|
|
||||||
throw const ProcessException('zip', <String>[], 'Failed to unzip');
|
|
||||||
}
|
}
|
||||||
targetDirectory.childFile(gzippedTarFile.fileSystem.path.basenameWithoutExtension(gzippedTarFile.path))
|
targetDirectory.childFile(gzippedTarFile.fileSystem.path.basenameWithoutExtension(gzippedTarFile.path))
|
||||||
.createSync();
|
.createSync();
|
||||||
|
Loading…
Reference in New Issue
Block a user