chore: migrate from react-native-fs to expo-file-system#7428
Draft
janicduplessis wants to merge 2 commits into
Draft
chore: migrate from react-native-fs to expo-file-system#7428janicduplessis wants to merge 2 commits into
janicduplessis wants to merge 2 commits into
Conversation
`createAndShareStateDumpFile` is the only caller of `react-native-fs`
that touches the public Android Downloads folder, which has no
expo-file-system equivalent. The Android-only Downloads copy was
redundant β the share sheet handles cross-platform export of the
dump JSON via the document directory, which works the same on iOS
and Android.
Swap the four `RNFS` calls for their `expo-file-system` equivalents
(`documentDirectory`, `writeAsStringAsync`, `deleteAsync`) and drop
the `RNFS.DownloadDirectoryPath` branch. The `getInfoAsync`
existence check is also gone β `deleteAsync({ idempotent: true })`
already no-ops when the file is missing.
`expo-file-system` is added as a direct dependency at the version
already pulled in transitively through `expo`.
Migrates the four remaining `react-native-fs` callers to the
equivalent `expo-file-system` APIs and removes the package from the
dependency list. `expo-file-system` is already pulled in transitively
via the `expo` SDK and was promoted to a direct dependency in the
preceding commit.
- DappBrowser screenshot store (`screenshots.ts`): `copyFile` β
`copyAsync`, `unlink` β `deleteAsync({ idempotent: true })`,
`readDir` β `readDirectoryAsync`. The orphan-prune path was
restructured around filename strings since `readDirectoryAsync`
returns plain names rather than `ReadDirItem` objects.
- Cloud backup (`cloudBackup.ts`): `writeFile`/`unlink` β
`writeAsStringAsync`/`deleteAsync`. RNCloudFs still wants a POSIX
path for `sourcePath.path`, so the `file://` URI is stripped
before handing off.
- Migrations v16 (`migrations.ts`): `unlink(path.join(...))` β
`deleteAsync(URI, { idempotent: true })`. `cacheDirectory` already
ends with a trailing slash, so `path.join` is no longer needed.
- Pinata upload (`pinata.ts`): `RNFS.uploadFiles({...}).promise` β
`FileSystem.uploadAsync(url, fileUri, { uploadType: MULTIPART, ...})`.
The caller-supplied `filename` is preserved via
`pinataMetadata.name` since expo-file-system's multipart Content-
Disposition derives the filename from the URI's basename and there
is no override option.
Also renames a stale `screenshotWithRNFSPath` local in the dapp
browser hook to `screenshotWithFullPath`.
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes APP-####
What changed (plus any additional context for devs)
Removes
react-native-fsfrom the app and routes every caller throughexpo-file-system, which is already pulled in transitively via theexpoSDK and is now promoted to a direct dependency. The motivation was twofold:react-native-fsis unmaintained and needed a local patch to survive RN 0.81 (PromiseImpl.rejectnow rejects nullcode), and the API surface we use is small and maps cleanly toexpo-file-system.Changes by call site:
src/components/DappBrowser/screenshots.tsβcopyFile/unlink/readDirβcopyAsync/deleteAsync({ idempotent: true })/readDirectoryAsync. The orphan-prune path was reshaped slightly:readDirectoryAsyncreturns plain filename strings, where RNFS returnedReadDirItemobjects with apathfield, so the file URIs are now built explicitly fromdocumentDirectory + name.src/handlers/cloudBackup.tsβwriteFile/unlinkβwriteAsStringAsync/deleteAsync. RNCloudFs'ssourcePath.pathstill expects a POSIX path, so thefile://URI is stripped before the cloud copy.src/model/migrations.ts(migration v16) βunlink(path.join(...))βdeleteAsync(URI, { idempotent: true }).cacheDirectoryalready ends with a trailing slash, sopathis no longer needed.src/handlers/pinata.tsβRNFS.uploadFiles({...}).promiseβFileSystem.uploadAsync(url, fileUri, { uploadType: MULTIPART, ... }). expo-file-system derives the multipart filename from the URI's basename and has no override; to preserve the caller-supplied filename, it's passed throughpinataMetadata.namein the form parameters, which Pinata uses for the pin name.src/screens/Diagnostics/helpers/createAndShareStateDumpFile.tsβ samedocumentDirectory/writeAsStringAsync/deleteAsyncswap. The Android-onlyRNFS.DownloadDirectoryPathwrite was redundant with the share sheet that follows and is dropped βexpo-file-systemhas no equivalent for the public Downloads folder, but the cross-platform share sheet ("Save to Files", Drive, AirDrop, etc.) already covers the developer-export use case on both platforms.react-native-fsis removed frompackage.json;base-64(its sub-dep) drops out of the lockfile too.Screen recordings / screenshots
n/a β equivalent behaviour, no UI surface change.
What to test
rainbow-token-list.json/rainbow-token-list-etag.jsoninto the cache dir, then upgrade to this build; verify those files are gone after first launch (or simply that the migration runs without error in a fresh install).