[flutter_tools] implement safe file copy with multiple fallbacks#69000
[flutter_tools] implement safe file copy with multiple fallbacks#69000jonahwilliams merged 4 commits intoflutter:masterfrom
Conversation
| try { | ||
| return wrapFile(delegate.copySync(newPath)); | ||
| } on FileSystemException { | ||
| // Proceed below |
There was a problem hiding this comment.
If we had more information about this case, we could report a good bug. Consider recording an analytics event.
|
If we do not see the fallback event in analytics after a stable cycle or so, we can delete the fallback code |
| // Proceed below | ||
| } | ||
| // If the copy failed but both of the above checks passed, copy the bytes | ||
| // directly. |
There was a problem hiding this comment.
If something goes wrong with this, we should probably delete the destination file.
| }, platform: _platform, failureMessage: 'Flutter failed to copy $path to $newPath due to unknown error'); | ||
| // The original copy failed, but the manual copy worked. Report an analytics event to | ||
| // track this to determine if this code path is actually hit. | ||
| ErrorHandlingEvent('copy-fallback').send(); |
There was a problem hiding this comment.
This will give us the count of copySync failing, but the manual copy succeeding. Would any other information be helpful?
There was a problem hiding this comment.
If one of the file open checks fails, it is likely to be a regular old permission issue. If not, crash logging will handle it.
if the fallback copySync fails, assuming it is not one of the known issues, crash logging will handle that too
Description
The tool observes a large number of unhandled exceptions during the file copy portion of flutter create. it is difficult to tell whether the permission issue is caused by the source/destination, or whether it is due to a bug in dart:io.
To work around this, implement a permission check for both the source and dest files. If either fails, the tool can exit with a more specific message.
If these checks pass, then perform the actual copy. If the copy fails, fallback to manually copying the bytes