HomePhabricator
Diffusion Comm 24beb2966f16

[native] Unlink files as necessary in `useUploadSelectedMedia`

Tags
None
Referenced Files
F519911: 50b63b.png
May 3 2023, 6:53 AM
File Not Attached
F519910: 8e30ed.png
May 3 2023, 6:53 AM
File Not Attached
F519780: b07830.png
May 3 2023, 6:53 AM
File Not Attached
F519779: 020492.png
May 3 2023, 6:53 AM
File Not Attached
F519777: b0aa05.png
May 3 2023, 6:53 AM
File Not Attached
F519774: ed2cb6.png
May 3 2023, 6:53 AM
File Not Attached
F519773: 3a90ca.png
May 3 2023, 6:53 AM
File Not Attached
Subscribers
None

Description

[native] Unlink files as necessary in useUploadSelectedMedia

Summary:
expo-image-picker will always copy the contents of image into cache and provide a URL to cached image:

3a90ca.png (220×1 px, 48 KB)

ed2cb6.png (528×1 px, 124 KB)

As a result we'll ALWAYS need to unlink the selection.uri. We also clean up processedMedia.uploadURI if necessary.

Test Plan:
Tested small images which weren't processed and large images which were processed. Logged the contents of selection, processedMedia, and urisToBeDisposed. When I commented out the unlink line (159), I was able to open all of the images in Finder. When I uncommented the unlink line, all of the images were inaccessible because they'd been removed:

b0aa05.png (590×1 px, 141 KB)

Before:

020492.png (2×3 px, 2 MB)

After:

b07830.png (1×2 px, 550 KB)

Tested Android by ensuring that files remained in caches when unlink was commented out and weren't in caches when unlink was uncommented:

Selected an image avatar and ensured contents were as before:

8e30ed.png (208×1 px, 52 KB)

Selected an image avatar with unlink left out and observed that new files were added:

50b63b.png (330×1 px, 78 KB)

Reviewers: ashoat, ginsu

Reviewed By: ashoat

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D7704

Details

Provenance
atulAuthored on May 3 2023, 6:45 AM
Reviewer
ashoat
Differential Revision
D7704: [native] Unlink files as necessary in `useUploadSelectedMedia`
Parents
rCOMM8f49a3be9b9c: [native] Get rid of null check in `useUploadSelectedMedia`
Branches
Unknown
Tags
Unknown