Page MenuHomePhabricator

D7704.id26023.diff
No OneTemporary

D7704.id26023.diff

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

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)

Event Timeline