-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Windows] readDir()
.isFile()
and .isDirectory()
don't resolve correctly
#81
Comments
readDir
.isFile() and .isDirectory() dont resolve correctly (at least) on react-native-windows
readDir
.isFile() and .isDirectory() dont resolve correctly (at least) on react-native-windowsreadDir()
.isFile() and .isDirectory() dont resolve correctly (at least) on react-native-windows
Thanks @AchillesChristianPrinz ! Looking at the
I agree. The current goofy design is inherited from the original upstream code. I thought about this exact change, among other stuff, for v3 of the library (to keep the current v2 as close to the drop-in replacement of the original library, as possible); but v3 is unlikely to happen any time soon. So, for now the fix will be to ensure correct string values are assigned to related fields and constants on the native side on Windows and Android; I'll do it when updating Windows version to [email protected] (which is still on hold, because #76). |
Thanks for your quick response. This won't probably last long since the are already @ preview5 or so. |
I have the same problem on iOS (RN 0.76.1), isFile and isDirectory resolve always "false". |
@alessandro-bottamedi it might be different. On iOS there are more resource types, beyond directory and regular file: https://developer.apple.com/documentation/foundation/nsurlfileresourcetype. As of now (the same as in the original upstream), |
But with RN 0.75 and version 2.28 of the package, isFile and isDirectory respond correctly with the same files… |
readDir()
.isFile() and .isDirectory() dont resolve correctly (at least) on react-native-windowsreadDir()
.isFile() and .isDirectory() dont resolve correctly on iOS, macOS, Windows
readDir()
.isFile() and .isDirectory() dont resolve correctly on iOS, macOS, WindowsreadDir()
.isFile()
and .isDirectory()
don't resolve correctly on iOS, macOS, Windows
UpdateIt turns out, making this library and its Example App to work with [email protected] (New Arch) on Windows is an undertaking too large for me, unless it is sponsored by somebody (#76 (comment)). For similar reasons I can't support multiple versions of RN / fix something in older versions of the library. Thus, the Windows part of the issue will be put On Hold indefinitely. At the same time, I found & fixed the issue for iOS / macOS (it turned out to be a regression introduced when implementing support of security-scoped URLs). I'll probably release it over the weekend, or the next week, once complete some more fixes related to special characters support in path names (#82, #85) on Android / iOS / macOS. |
Maybe I'll take the time to make a PR for the tasks on the windows side, once you released the changes. I just have to figure out how to build and test the project. But the other way around, I can build and test Windows and Android only, so if I have to make changes on the js side you'll probably have to make regression tests for iOS/MacOS. |
Yeah... that's the crux of the problem — Example App depends on
I believe, the fix here should be on native side — just correcting the values assigned to related fields and constants to ensure they are all strings. Quite simple, but a pain to test without being able to build Example App. |
readDir()
.isFile()
and .isDirectory()
don't resolve correctly on iOS, macOS, WindowsreadDir()
.isFile()
and .isDirectory()
don't resolve correctly
You're totally right - This is all on the native side. I already got this patched in my app. I got the example app running on windows, but only 10/25 tests passed. 2 of the failing were missing an When this is done I'll fix the "Umlauts" and
I'm doing this on the uwp Version 0.76 that you installed for the example app. As it seems it's still possible to do it "the old way". Maybe there has to be a way for the example app to release the dependency on |
In the
readDir
method the resulting callbacksisFile()
andisDirectory()
compare the wrong types.On the JS side you assume that
file.type
is a string when comparing it to any of those values:const { FileTypeDirectory, FileTypeRegular } = RNFS.getConstants()
react-native-fs/src/index.ts
Line 64 in 5df8019
react-native-fs/src/index.ts
Line 65 in 5df8019
But at least on react-native-windows and probably also on android the type of
file.type
is anumber
. This results in both callbacks always resolving to false wheter it is a file or a directory.Here are the assignments on the native side:
react-native-fs/android/src/main/java/com/drpogodin/reactnativefs/ReactNativeFsModule.kt
Line 529 in 5df8019
react-native-fs/windows/ReactNativeFs/ReactNativeModule.cpp
Line 511 in 5df8019
My temporary solution (just tested on rn-windows) is to cast the type to a String:
But the whole thing should probably be deprecated and the
type: 'file' | 'directory'
be passed through from the native side, instead of using two callbacks to resolve a possible number or string to a booleanThe text was updated successfully, but these errors were encountered: