Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3736323
D8739.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
D8739.diff
View Options
diff --git a/native/media/file-utils.js b/native/media/file-utils.js
--- a/native/media/file-utils.js
+++ b/native/media/file-utils.js
@@ -1,6 +1,7 @@
// @flow
import base64 from 'base-64';
+import * as ExpoFileSystem from 'expo-file-system';
import * as MediaLibrary from 'expo-media-library';
import invariant from 'invariant';
import { Platform } from 'react-native';
@@ -57,14 +58,14 @@
const { mediaNativeID } = optionalInputs;
const steps = [];
- let assetInfoPromise, newLocalURI;
+ let assetInfoPromise, assetURI;
const inputPath = pathFromURI(inputURI);
if (mediaNativeID && (!inputPath || optionalFields.orientation)) {
assetInfoPromise = (async () => {
const { steps: assetInfoSteps, result: assetInfoResult } =
await fetchAssetInfo(mediaNativeID);
steps.push(...assetInfoSteps);
- newLocalURI = assetInfoResult.localURI;
+ assetURI = assetInfoResult.localURI;
return assetInfoResult;
})();
}
@@ -150,11 +151,18 @@
}
let finalURI = uri;
- if (newLocalURI && newLocalURI !== uri) {
- finalURI = newLocalURI;
+ // prefer asset URI, with one exception:
+ // if the target URI is a file in our app local cache dir, we shouldn't
+ // replace it because it was already preprocessed by either our media
+ // processing logic or cropped by expo-image-picker
+ const isFileInCacheDir =
+ uri.includes(temporaryDirectoryPath) ||
+ uri.includes(ExpoFileSystem.cacheDirectory);
+ if (assetURI && assetURI !== uri && !isFileInCacheDir) {
+ finalURI = assetURI;
console.log(
'fetchAssetInfo returned localURI ' +
- `${newLocalURI} when we already had ${uri}`,
+ `${assetURI} when we already had ${uri}`,
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 10, 6:03 AM (8 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2845768
Default Alt Text
D8739.diff (1 KB)
Attached To
Mode
D8739: [native] Fix cropped avatar selection
Attached
Detach File
Event Timeline
Log In to Comment