-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[camera_avfoundation] ios saving path #10832
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
base: main
Are you sure you want to change the base?
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
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.
Code Review
This pull request correctly changes the iOS file storage path from documentDirectory to temporaryDirectory to align with Android's behavior, improving cross-platform consistency. I have one suggestion to improve code clarity by renaming a variable that became misleading due to this change.
.../camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/DefaultCamera.swift
Outdated
Show resolved
Hide resolved
|
Thanks for the submission! This will need the remaining items in the checklist addressed before it moves forward with review. If you have any questions about completing those steps that aren’t addressed in the linked documentation, please let us know. |
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.
Code Review
The pull request updates the iOS camera plugin to store captured pictures and videos in the system's temporaryDirectory instead of the application's documentDirectory. This change aligns the iOS behavior with Android's cache directory usage. The CHANGELOG.md has been updated to reflect this as a breaking change, and the pubspec.yaml version has been incremented accordingly.
stuartmorgan-g
left a comment
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 still needs tests before it can be reviewed, per the checklist.
| @@ -1,3 +1,8 @@ | |||
| ## 0.9.23 | |||
|
|
|||
| * **BREAKING CHANGES**: | |||
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.
In what scenario specifically are existing applications broken by this change? What action do package clients need to take?
If this does in fact need to be a breaking change, it will require correct versioning, and a cascading breaking change to camera, so would need significant discussion.
53e2fa8 to
7d94b9a
Compare
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.
Code Review
This pull request successfully updates the iOS file storage path for camera pictures and videos from the application's documentDirectory to the temporaryDirectory, aligning with Android's cache directory usage for consistency. The change is well-supported by a new test case that verifies the updated storage location. The CHANGELOG.md and pubspec.yaml files have been updated appropriately.
| } | ||
|
|
||
| func testCaptureToFile_mustSavePhotoToCameraPicturesDirectory() { | ||
| let expectedPath = "/tmp/camera/pictures/" |
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 expectedPath is hardcoded as "/tmp/camera/pictures/". While this is correct for the current implementation, it could be more robust to derive this path dynamically within the test, perhaps by calling the same utility function that constructs the path in DefaultCamera.swift (if exposed or mockable), or by inspecting FileManager.default.temporaryDirectory and appending the known subpaths. This would make the test less brittle if the subfolder structure changes in the future.
hellohuanlin
left a comment
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.
iOS now uses temporaryDirectory instead of documentDirectory for consistency with Android
I don't see why we want this "consistency". Apple's recommendation is to use documentDirectory for user generated files (so that it could be exported when connected to mac).
To fix the broken file, we could either (1) save to temp directory first, and move to document directory once done, or (2) save to document directory, and delete if error happens.
Description
Changed iOS file storage path from
documentDirectorytotemporaryDirectoryto ensure consistency with Android where files are stored in cache directory.Changes
temporaryDirectoryinstead ofdocumentDirectoryfor consistency with AndroidCode changes
Issues
flutter/flutter#166933
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3