Skip to content

Commit 99a5b3f

Browse files
authored
Use noExitOnFailure in flutter clean. (flutter#169966)
Closes flutter#108978.
1 parent 0c0406a commit 99a5b3f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/flutter_tools/lib/src/commands/clean.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:meta/meta.dart';
66

77
import '../../src/macos/xcode.dart';
88
import '../base/common.dart';
9+
import '../base/error_handling_io.dart';
910
import '../base/file_system.dart';
1011
import '../base/logger.dart';
1112
import '../build_info.dart';
@@ -118,6 +119,16 @@ class CleanCommand extends FlutterCommand {
118119

119120
@visibleForTesting
120121
void deleteFile(FileSystemEntity file) {
122+
try {
123+
ErrorHandlingFileSystem.noExitOnFailure(() {
124+
_deleteFile(file);
125+
});
126+
} on Exception catch (e) {
127+
globals.printError('Failed to remove ${file.path}: $e');
128+
}
129+
}
130+
131+
void _deleteFile(FileSystemEntity file) {
121132
// This will throw a FileSystemException if the directory is missing permissions.
122133
try {
123134
if (!file.existsSync()) {

packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'package:args/command_runner.dart';
66
import 'package:file/memory.dart';
77
import 'package:file_testing/file_testing.dart';
8+
import 'package:flutter_tools/src/base/error_handling_io.dart';
89
import 'package:flutter_tools/src/base/file_system.dart';
910
import 'package:flutter_tools/src/base/logger.dart';
1011
import 'package:flutter_tools/src/base/platform.dart';
@@ -234,7 +235,13 @@ void main() {
234235
'$CleanCommand handles missing delete permissions',
235236
() async {
236237
final FileExceptionHandler handler = FileExceptionHandler();
237-
final FileSystem fileSystem = MemoryFileSystem.test(opHandle: handler.opHandle);
238+
239+
// Ensures we handle ErrorHandlingFileSystem appropriately in prod.
240+
// See https://github.com/flutter/flutter/issues/108978.
241+
final FileSystem fileSystem = ErrorHandlingFileSystem(
242+
delegate: MemoryFileSystem.test(opHandle: handler.opHandle),
243+
platform: windowsPlatform,
244+
);
238245
final File throwingFile = fileSystem.file('bad')..createSync();
239246
handler.addError(
240247
throwingFile,

0 commit comments

Comments
 (0)