-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[cross_file] always set browser blob when constructing XFile from data #8611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cross_file] always set browser blob when constructing XFile from data #8611
Conversation
|
@ditman I tried to run the tests for cross_file locally, but I can't seem to get that working (been a while since I last ran tests for the packages repo :P ) I tried to follow https://github.com/flutter/flutter/blob/master/docs/ecosystem/testing/Plugin-Tests.md#web-tests to work? Am I missing a setup step? I updated my chromedriver, but when I try to run the tests I get: Logs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unnamed constructor always sets the blob when the bytes are provided.
This one didn't but we can always do that since the bytes are required for this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comment on preferring the passed in path to the generated blob URL for a XFile.fromData.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will create a wrong XFile if browserBlob is passed and its path is overridden, down the line, because we've been telling people to use .path on the XFile to access its blob URL; so in this case, if we've created a non empty blob, the path should NOT be used.
I think that in this case, we need to warn users who pass a path that it'll be ignored.
Try instead: dit@dit:/work/flutter/packages/packages/cross_file$ dart test --platform=chrome
00:03 +0: loading test/x_file_html_test.dart
Compiled 14,179,976 input bytes (9,171,791 characters source) to 1,187,453 characters JavaScript in 3.79 seconds using N/A MB of memory
00:06 +13: All tests passed!You can run the tests for the VM by omitting the platform argument. dit@dit:/work/flutter/packages/packages/cross_file$ dart test
00:00 +12: All tests passed!If the |
0373cfc to
dfe8575
Compare
|
This is ready for another review. The test was updated to verify the path a bit more strictly and I documented that we will be ignoring the path on the web if there are bytes for the file. When running the tests, I noticed that I got a popup saying the chrome process wanted me to "Continue a download", but after accepting that, the tests finished but the process seemed to hang. Is that avoidable when running the tests in a headless chrome instance? |
|
Hey @ditman are you able to give this another review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
auto label is removed for flutter/packages/8611, Failed to merge flutter/packages/8611 with FormatException: Unexpected end of input (at character 1) ^ |
flutter/packages@41c6b3d...1a7075b 2025-10-29 [email protected] Roll Flutter from 7cf0dc1 to df72035 (23 revisions) (flutter/packages#10322) 2025-10-29 [email protected] [cross_file] always set browser blob when constructing XFile from data (flutter/packages#8611) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This PR fixes a bug where files created with
XFile.fromData()would ignore the provided bytes if the path is present, too.Now if the bytes and the path are both provided, the content is read from the bytes directly.
Fixes flutter/flutter#163044
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.