[flutter_tools] check for permission issues when copying file#63540
[flutter_tools] check for permission issues when copying file#63540fluttergithubbot merged 15 commits intoflutter:masterfrom
Conversation
…nto permission_issue
zanderso
left a comment
There was a problem hiding this comment.
I might have given bad advice that it's easy to make ErrorHandlingFileSystem handle what _validateReadPermissions is doing. But as written, because openSync() gets forwarded to the delegate file system, I don't think this change will give the tool exit. It will still give the crash.
| /// If this fails with a certain error code, the [ErrorHandlingFileSystem] will | ||
| /// trigger a tool exit with a better message. | ||
| void _validateReadPermissions(File file) { | ||
| final RandomAccessFile randomAccessFile = file.openSync(); |
There was a problem hiding this comment.
It doesn't look like ErrorHandlingFile overrides openSync().
There was a problem hiding this comment.
Ahh, yeah I did not run my integration test with this change after switching to the error handling file system. I could modify this so that it skips the random access file.
| final File file = fs.file('file'); | ||
|
|
||
| const String expectedMessage = 'The flutter tool cannot access the file'; | ||
| expect(() async => await file.writeAsBytes(<int>[0]), |
There was a problem hiding this comment.
This test is good. A test that you get a tool exit for the operations that _validateReadPermissions is also needed.
| return fileCount; | ||
| } | ||
|
|
||
| /// Attempt to the length from the file to ensure that read permissions are correct. |
There was a problem hiding this comment.
| /// Attempt to the length from the file to ensure that read permissions are correct. | |
| /// Attempt to find the length from the file to ensure that read permissions are correct. |
|
( I haven't actually verified that reading the file length hits the permission bit check on windows) |
…nto permission_issue
| setupWriteMocks( | ||
| mockFileSystem: mockFileSystem, | ||
| fs: fs, | ||
| errorCode: 5, |
There was a problem hiding this comment.
Include this above with the other constants starting on line 83.
Description
We're seeing a large number of file system crashes on the latest stable. To determine whether it is an issue reading or copying, first attempt to access some bytes of the template file to force any permissions errors to be shaken out.
If this is the case, exit with an informative error instead of crashing.
#63528