Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3399093
D7704.id26023.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.id26023.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,10 @@
let uploadedMedia: UploadMultimediaResult;
try {
uploadedMedia = await uploadProcessedMedia(processedMedia);
+ console.log(urisToBeDisposed);
+ 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
Tue, Dec 3, 1:45 AM (20 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2609706
Default Alt Text
D7704.id26023.diff (1 KB)
Attached To
Mode
D7704: [native] Unlink files as necessary in `useUploadSelectedMedia`
Attached
Detach File
Event Timeline
Log In to Comment