Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3398672
D7704.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D7704.diff
View Options
diff --git a/native/avatars/avatar-hooks.js b/native/avatars/avatar-hooks.js
--- a/native/avatars/avatar-hooks.js
+++ b/native/avatars/avatar-hooks.js
@@ -5,6 +5,7 @@
import * as React from 'react';
import { Platform } from 'react-native';
import Alert from 'react-native/Libraries/Alert/Alert.js';
+import filesystem from 'react-native-fs';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { uploadMultimedia } from 'lib/actions/upload-actions.js';
@@ -121,11 +122,16 @@
return React.useCallback(
async (selection: NativeMediaSelection) => {
setProcessingOrUploadInProgress(true);
+ const urisToBeDisposed: Set<string> = new Set([selection.uri]);
let processedMedia;
try {
processedMedia = await processSelectedMedia(selection);
+ if (processedMedia.uploadURI) {
+ urisToBeDisposed.add(processedMedia.uploadURI);
+ }
} catch (e) {
+ urisToBeDisposed.forEach(filesystem.unlink);
Alert.alert(
'Media processing failed',
'Unable to process selected media.',
@@ -135,6 +141,7 @@
}
if (!processedMedia.success) {
+ urisToBeDisposed.forEach(filesystem.unlink);
Alert.alert(
'Media processing failed',
'Unable to process selected media.',
@@ -146,7 +153,9 @@
let uploadedMedia: UploadMultimediaResult;
try {
uploadedMedia = await uploadProcessedMedia(processedMedia);
+ urisToBeDisposed.forEach(filesystem.unlink);
} catch {
+ urisToBeDisposed.forEach(filesystem.unlink);
Alert.alert(
'Media upload failed',
'Unable to upload selected media. Please try again.',
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 2, 11:59 PM (21 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2609359
Default Alt Text
D7704.diff (1 KB)
Attached To
Mode
D7704: [native] Unlink files as necessary in `useUploadSelectedMedia`
Attached
Detach File
Event Timeline
Log In to Comment