mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[flutter_tools] fix Cannot delete file ENOENT from fuchsia_asset_builder (#119867)
* fix * add test
This commit is contained in:
parent
be4c8c0eb1
commit
9a7e18701e
@ -116,7 +116,11 @@ class Config {
|
||||
if (managed) {
|
||||
rethrow;
|
||||
} else {
|
||||
_file.deleteSync();
|
||||
try {
|
||||
_file.deleteSync();
|
||||
} on FileSystemException {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
} on Exception catch (err) {
|
||||
_logger
|
||||
|
@ -130,6 +130,26 @@ void main() {
|
||||
expect(bufferLogger.errorText, contains(r'sudo chown -R $(whoami) /testfile'));
|
||||
});
|
||||
|
||||
testWithoutContext('Config.createForTesting does not error when failing to delete a file', () {
|
||||
final BufferLogger bufferLogger = BufferLogger.test();
|
||||
|
||||
final FileExceptionHandler handler = FileExceptionHandler();
|
||||
final MemoryFileSystem fs = MemoryFileSystem.test(opHandle: handler.opHandle);
|
||||
final File file = fs.file('testfile')
|
||||
// We write invalid JSON so that we test catching a `FormatException`
|
||||
..writeAsStringSync('{"This is not valid JSON"');
|
||||
handler.addError(
|
||||
file,
|
||||
FileSystemOp.delete,
|
||||
const FileSystemException(
|
||||
"Cannot delete file, path = 'testfile' (OS Error: No such file or directory, errno = 2)",
|
||||
),
|
||||
);
|
||||
|
||||
// Should not throw a FileSystemException
|
||||
Config.createForTesting(file, bufferLogger);
|
||||
});
|
||||
|
||||
testWithoutContext('Config in home dir is used if it exists', () {
|
||||
memoryFileSystem.file('.flutter_example').writeAsStringSync('{"hello":"bar"}');
|
||||
config = Config(
|
||||
|
Loading…
Reference in New Issue
Block a user