diff --git a/packages/flutter_tools/lib/src/base/error_handling_io.dart b/packages/flutter_tools/lib/src/base/error_handling_io.dart index 41bc27e8859..e7086141d92 100644 --- a/packages/flutter_tools/lib/src/base/error_handling_io.dart +++ b/packages/flutter_tools/lib/src/base/error_handling_io.dart @@ -124,7 +124,7 @@ class ErrorHandlingFileSystem extends ForwardingFileSystem { @override Directory get systemTempDirectory { - return directory(delegate.systemTempDirectory); + return _runSync(() => directory(delegate.systemTempDirectory), platform: _platform); } @override diff --git a/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart b/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart index a43367c3419..c4b661dfaa6 100644 --- a/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart +++ b/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart @@ -884,7 +884,7 @@ void main() { }); }); - testWithoutContext("ErrorHandlingFileSystem.systemTempDirectory wraps delegates filesystem's systemTempDirectory", () { + testWithoutContext("ErrorHandlingFileSystem.systemTempDirectory wraps delegate filesystem's systemTempDirectory", () { final FileExceptionHandler exceptionHandler = FileExceptionHandler(); final MemoryFileSystem delegate = MemoryFileSystem.test( @@ -921,6 +921,35 @@ Please ensure that the SDK and/or project is installed in a location that has re ); }); + testWithoutContext("ErrorHandlingFileSystem.systemTempDirectory handles any exception thrown by the delegate's systemTempDirectory implementation", () { + final FileExceptionHandler exceptionHandler = FileExceptionHandler(); + exceptionHandler.addTempError( + FileSystemOp.create, + const FileSystemException( + 'Creation of temporary directory failed', + 'some/temp/path', + OSError( + 'No space left on device', + 28, + ), + ), + ); + + final MemoryFileSystem delegate = MemoryFileSystem.test( + opHandle: exceptionHandler.opHandle, + ); + + final FileSystem fs = ErrorHandlingFileSystem( + delegate: delegate, + platform: FakePlatform(), + ); + + expect( + () => fs.systemTempDirectory, + throwsToolExit(message: 'Free up space and try again.'), + ); + }); + group('ProcessManager on windows throws tool exit', () { const int kDeviceFull = 112; const int kUserMappedSectionOpened = 1224;